Athlete.java
// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by EntityEmbeddable.vsl in andromda-ejb3-cartridge on 08/08/2014 12:21:04.
//
package org.andromda.demo.ejb3.athlete;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* <p>
* TODO: Model Documentation for org.andromda.demo.ejb3.athlete.Athlete
* </p>
*
* Autogenerated POJO EJB class for Athlete containing the
* bulk of the entity implementation.
*
* This is autogenerated by AndroMDA using the EJB3
* cartridge.
*
* DO NOT MODIFY this class.
*/
@Entity
@Table(name="ATHLETE")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("A")
@NamedQuery(name="Athlete.findAll", query="SELECT a FROM Athlete AS a")
public class Athlete
implements Serializable, Comparable<Athlete>{
private static final long serialVersionUID = 706808658504640700L;
// ----------- 2 Attribute Definitions ------------
protected Long number;
protected String name;
// -------- 2 Attribute Accessors ----------
/**
* <p>
* TODO: Model Documentation for number
* </p>
* Get the number property.
* @return Long The value of number
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="NUMBER", nullable=false, insertable=true, updatable=true)
public Long getNumber()
{
return this.number;
}
/**
* <p>
* TODO: Model Documentation for number
* </p>
* Set the number property.
* @param value the new value
*/
public void setNumber(Long value)
{
this.number = value;
}
/**
* <p>
* TODO: Model Documentation for name
* </p>
* Get the name property.
* @return String The value of name
*/
@Column(name="NAME", nullable=false, insertable=true, updatable=true, length=50)
@NotNull(message="name is required")
@Size(max=50)
public String getName()
{
return this.name;
}
/**
* <p>
* TODO: Model Documentation for name
* </p>
* Set the name property.
* @param value the new value
*/
public void setName(String value)
{
this.name = value;
}
// ------------- 0 Relations ------------------
// --------------- Constructors -----------------
/**
* Default empty no-arg constructor
*/
public Athlete()
{
// 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
*/
public Athlete(String name)
{
this.name = name;
}
// -------- 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 Athlete))
{
return false;
}
final Athlete that = (Athlete)object;
if (this.getNumber() == null || that.getNumber() == null || !this.getNumber().equals(that.getNumber()))
{
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 + (getNumber() == null ? 0 : getNumber().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("Athlete(");
sb.append(" number=").append(getNumber());
sb.append(" name=").append(getName());
sb.append(")");
return sb.toString();
}
/**
* @see Comparable#compareTo
*/
@Override
public int compareTo(Athlete o)
{
int cmp = 0;
if (this.getNumber() != null)
{
cmp = this.getNumber().compareTo(o.getNumber());
}
else
{
if (this.getName() != null)
{
cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
}
}
return cmp;
}
}