Animal.java
// license-header java merge-point
//
// This file can be safely modified. If deleted it will be regenerated.
// Generated by Entity.vsl in andromda-ejb3-cartridge on 08/06/2014 10:56:20.
//
package org.andromda.demo.ejb3.animal;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
/**
* Autogenerated POJO EJB3 implementation class for Animal.
*
* Add any manual implementation within this class. This class will NOT
* be overwritten with incremental changes.
*
* <p>
* TODO: Model Documentation for org.andromda.demo.ejb3.animal.Animal
* </p>
*
*/
@Entity
@Table(name = "ANIMAL")
@EntityListeners({AnimalListener.class})
// Uncomment to enable caching for Animal
// @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.TRANSACTIONAL)
@NamedQueries
({
@NamedQuery(name = "Animal.findAll", query = "SELECT a FROM Animal AS a"),
@NamedQuery(name = "Animal.findByType", query = "SELECT a from Animal as a WHERE a.type = :type")
@NamedQuery(name = "Animal.deleteByCarnivor", query = "delete from Animal as a where a.carnivor = :carnivor")
})
public class Animal
extends AnimalEmbeddable
implements Comparable<Animal>
{
/**
* The serial version UID of this class required for serialization.
*/
private static final long serialVersionUID = -4363106082863672597L;
// --------------- constructors -----------------
/**
* Default Animal constructor
*/
public Animal()
{
super();
}
/**
* Implementation for the constructor with all POJO attributes except auto incremented identifiers.
* This method sets all POJO fields defined in this/super class to the
* values provided by the parameters.
* @param name
* @param types
* @param carnivor
*/
public Animal(String name, Collection<String> types, boolean carnivor)
{
super(name, types, carnivor);
}
// -------------- Entity Methods -----------------
// --------------- Lifecycle callbacks -----------------
/**
* <p>
* TODO: Model Documentation for prePersist
* </p>
*/
@PrePersist
public void prePersist()
{
System.out.println("pre persist...");
}
/**
* <p>
* TODO: Model Documentation for preUpdate
* </p>
*/
@PreUpdate
public void preUpdate()
{
System.out.println("pre update...");
}
/**
* @see Comparable#compareTo
*/
@Override
public int compareTo(Animal o)
{
int cmp = 0;
if (this.getName() != null)
{
cmp = this.getName().compareTo(o.getName());
}
/*else
{
if (this.getTypes() != null)
{
// Compare Collection sizes for ordering
cmp = (cmp != 0 ? cmp : Math.abs(this.getTypes().size()-o.getTypes().size()));
}
}*/
return cmp;
}
}