// license-header java merge-point // // Attention: Generated code! Do not modify by hand! // Generated by EntityEmbeddable.vsl in andromda-ejb3-cartridge on 09/18/2014 16:56:06. // package org.andromda.test.howto3.b; import java.io.Serializable; import java.util.Date; import java.util.HashSet; import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.validation.constraints.NotNull; /** *

* TODO: Model Documentation for org.andromda.test.howto3.b.Person *

* * 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") @NamedQuery(name="Person.findAll", query="SELECT p FROM Person AS p") public class Person implements Serializable, Comparable{ private static final long serialVersionUID = 2077335445406713868L; // ----------- 3 Attribute Definitions ------------ protected String name; protected Date birthDate; protected Long id; // --------- 1 Relationship Definitions ----------- protected Set cars = new HashSet(); // ---- Manageable Display Attributes (Transient) ----- // -------- 3 Attribute Accessors ---------- /** *

* TODO: Model Documentation for name *

* Get the name property. * @return String The value of name */ @Column(name="NAME", nullable=false, insertable=true, updatable=true) @NotNull(message="name is required") public String getName() { return this.name; } /** *

* TODO: Model Documentation for name *

* Set the name property. * @param value the new value */ public void setName(String value) { this.name = value; } /** *

* TODO: Model Documentation for birthDate *

* Get the birthDate property. * @return Date The value of birthDate */ @Column(name="BIRTH_DATE", nullable=false, insertable=true, updatable=true) @Temporal(TemporalType.TIMESTAMP) @NotNull(message="birthDate is required") public Date getBirthDate() { return this.birthDate; } /** *

* TODO: Model Documentation for birthDate *

* Set the birthDate property. * @param value the new value */ public void setBirthDate(Date value) { this.birthDate = value; } /** *

* TODO: Model Documentation for id *

* 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 this.id; } /** *

* TODO: Model Documentation for id *

* Set the id property. * @param value the new value */ public void setId(Long value) { this.id = value; } // ------------- 1 Relations ------------------ /** *

* TODO: Model Documentation for cars *

* Get the cars Collection * @return Set */ @OneToMany(mappedBy="owner") public Set getCars() { return this.cars; } /** *

* TODO: Model Documentation for cars *

* Set the cars * @param carsIn */ public void setCars (Set carsIn) { this.cars = carsIn; } // --------------- Constructors ----------------- /** * Default empty no-arg constructor */ public Person() { // Default empty constructor } /** * Constructor with all updatable Entity attributes except auto incremented identifiers. * * @param name String value for the name property required=true lower=1 * @param birthDate Date value for the birthDate property required=true lower=1 */ public Person(String name, Date birthDate) { this.name = name; this.birthDate = birthDate; } /** * Constructor with all Entity attribute values and CMR relations. * * @param name String value for the name property * @param birthDate Date value for the birthDate property * @param cars Set value for the cars relation */ public Person(String name, Date birthDate, Set cars) { // 2 updatableAttributes setName(name); setBirthDate(birthDate); // 1 relations setCars(cars); } // -------- 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' * @see Object#equals(Object) */ @Override public boolean equals(Object object) { if (null == object) { return false; } 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 * @see Object#hashCode */ @Override 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 * @see Object#toString */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Person("); sb.append(" name=").append(getName()); sb.append(" birthDate=").append(getBirthDate()); sb.append(" id=").append(getId()); sb.append(")"); return sb.toString(); } /** * @see Comparable#compareTo */ @Override public int compareTo(Person o) { int cmp = 0; if (this.getId() != null) { cmp = this.getId().compareTo(o.getId()); } else { if (this.getName() != null) { cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName())); } if (this.getBirthDate() != null) { cmp = (cmp != 0 ? cmp : this.getBirthDate().compareTo(o.getBirthDate())); } } return cmp; } }