// license-header java merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: EntityEmbeddable.vsl in andromda-ejb3-cartridge. // package org.andromda.howto2.rental; import java.io.Serializable; import java.util.Collection; import java.util.Date; import java.util.SortedSet; import java.util.TreeSet; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.Sort; import org.hibernate.annotations.SortType; /** * Autogenerated POJO EJB class for Person containing the * bulk of the entity implementation. * * This is autogenerated by AndroMDA using the EJB3 * cartridge. * * DO NOT MODIFY this class. * * * */ @Entity @Table(name = "PERSON") @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL) @NamedQueries ({ @NamedQuery(name = "Person.findAll", query = "from Person as person"), @NamedQuery(name = "Person.findByName", query = "from Person as person where person.name = :name"), @NamedQuery(name = "Person.findByNameOrBirthDate", query = "from org.andromda.howto2.rental.Person as person where person.name = :name or person.birthDate = :birthDate") }) public class Person implements Serializable { private static final long serialVersionUID = -709937363639956936L; // ----------- Attribute Definitions ------------ private String name; private Date birthDate; private Long id; // --------- Relationship Definitions ----------- private SortedSet cars = new TreeSet(); // ---- Manageable Display Attributes (Transient) ----- private Collection carsLabels; // --------------- Constructors ----------------- /** * Default empty constructor */ public Person() { // default null constructor } /** * Implementation for the constructor with all POJO attributes except auto incremented identifiers. * This method sets all POJO fields defined in this class to the values provided by * the parameters. * * @param name Value for the name property * @param birthDate Value for the birthDate property */ public Person(String name, Date birthDate) { setName(name); setBirthDate(birthDate); } /** * Constructor with all POJO attribute values and CMR relations. * * @param name Value for the name property * @param birthDate Value for the birthDate property * @param cars Value for the cars relation role */ public Person(String name, Date birthDate, SortedSet cars) { setName(name); setBirthDate(birthDate); setCars(cars); } // -------- Attribute Accessors ---------- /** * Get the name property. * * @return String The value of name */ @Column(name = "NAME", unique = true, nullable = false, insertable = true, updatable = true, length = 50) public String getName() { return name; } /** * Set the name property. * @param value the new value */ public void setName(String value) { this.name = value; } /** * Get the birthDate property. * * @return Date The value of birthDate */ @Column(name = "BIRTH_DATE", nullable = false, insertable = true, updatable = true) public Date getBirthDate() { return birthDate; } /** * Set the birthDate property. * @param value the new value */ public void setBirthDate(Date value) { this.birthDate = value; } /** * Get the id property. * * @return Long The value of id */ @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ID", nullable = false, insertable = true, updatable = true) public Long getId() { return id; } /** * Set the id property. * @param value the new value */ public void setId(Long value) { this.id = value; } // ------------- Relations ------------------ /** * Get the cars Collection * * @return SortedSet */ @OneToMany(mappedBy = "owner") @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL) @Sort(type = SortType.NATURAL) public SortedSet getCars() { return this.cars; } /** * Set the cars * * @param cars */ public void setCars (SortedSet cars) { this.cars = cars; } // -------- Manageable Attribute Display ----------- /** * Get the carsLabels * * @return Collection */ @Transient public Collection getCarsLabels() { return this.carsLabels; } /** * Set the carsLabels * * @param carsLabels */ public void setCarsLabels (Collection carsLabels) { this.carsLabels = carsLabels; } // -------- Common Methods ----------- /** * Indicates if the argument is of the same type and all values are equal. * * @param object The target object to compare with * @return boolean True if both objects a 'equal' */ public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof Person)) { return false; } final Person that = (Person)object; if (this.getId() == null || that.getId() == null || !this.getId().equals(that.getId())) { return false; } return true; } /** * Returns a hash code value for the object * * @return int The hash code value */ public int hashCode() { int hashCode = 0; hashCode = 29 * hashCode + (getId() == null ? 0 : getId().hashCode()); return hashCode; } /** * Returns a String representation of the object * * @return String Textual representation of the object displaying name/value pairs for all attributes */ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Person(="); sb.append("name: "); sb.append(getName()); sb.append(", birthDate: "); sb.append(getBirthDate()); sb.append(", id: "); sb.append(getId()); sb.append(")"); return sb.toString(); } }