Sponsor.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 java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* <p>
* TODO: Model Documentation for org.andromda.demo.ejb3.athlete.Sponsor
* </p>
*
* Autogenerated POJO EJB class for Sponsor containing the
* bulk of the entity implementation.
*
* This is autogenerated by AndroMDA using the EJB3
* cartridge.
*
* DO NOT MODIFY this class.
*/
@Entity
@Table(name="SPONSOR")
@NamedQuery(name="Sponsor.findAll", query="SELECT s FROM Sponsor AS s")
public class Sponsor
implements Serializable, Comparable<Sponsor>{
private static final long serialVersionUID = -5150522456724891050L;
// ----------- 3 Attribute Definitions ------------
protected int code;
protected String name;
protected Long sponsorId;
// --------- 2 Relationship Definitions -----------
protected TrackAthlete trackAthlete;
protected Set<GrantInfo> grantInfos = new HashSet<GrantInfo>();
// ---- Manageable Display Attributes (Transient) -----
// -------- 3 Attribute Accessors ----------
/**
* <p>
* TODO: Model Documentation for code
* </p>
* Get the code property.
* @return int The value of code
*/
@Column(name="CODE", nullable=false, insertable=true, updatable=true)
@NotNull(message="code is required")
public int getCode()
{
return this.code;
}
/**
* <p>
* TODO: Model Documentation for code
* </p>
* Set the code property.
* @param value the new value
*/
public void setCode(int value)
{
this.code = 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=64)
@NotNull(message="name is required")
@Size(max=64)
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;
}
/**
* <p>
* TODO: Model Documentation for sponsorId
* </p>
* Get the sponsorId property.
* @return Long The value of sponsorId
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="SPONSOR_ID", nullable=false, insertable=true, updatable=true)
public Long getSponsorId()
{
return this.sponsorId;
}
/**
* <p>
* TODO: Model Documentation for sponsorId
* </p>
* Set the sponsorId property.
* @param value the new value
*/
public void setSponsorId(Long value)
{
this.sponsorId = value;
}
// ------------- 2 Relations ------------------
/**
* <p>
* TODO: Model Documentation for trackAthlete
* </p>
* Get the trackAthlete
* @return TrackAthlete
*/
@ManyToOne(optional=false)
@JoinColumn(name="TRACK_ATHLETE_FK", insertable=true, updatable=true)
public TrackAthlete getTrackAthlete()
{
return this.trackAthlete;
}
/**
* <p>
* TODO: Model Documentation for trackAthlete
* </p>
* Set the trackAthlete
* @param trackAthleteIn
*/
public void setTrackAthlete(TrackAthlete trackAthleteIn)
{
this.trackAthlete = trackAthleteIn;
}
/**
* <p>
* TODO: Model Documentation for grantInfos
* </p>
* Get the grantInfos Collection
* @return Set<GrantInfo>
*/
@OneToMany(mappedBy="sponsor", fetch=FetchType.EAGER)
public Set<GrantInfo> getGrantInfos()
{
return this.grantInfos;
}
/**
* <p>
* TODO: Model Documentation for grantInfos
* </p>
* Set the grantInfos
* @param grantInfosIn
*/
public void setGrantInfos (Set<GrantInfo> grantInfosIn)
{
this.grantInfos = grantInfosIn;
}
// --------------- Constructors -----------------
/**
* Default empty no-arg constructor
*/
public Sponsor()
{
// Default empty constructor
}
/**
* Constructor with all updatable Entity attributes except auto incremented identifiers.
*
* @param code int value for the code property required=true lower=1
* @param name String value for the name property required=true lower=1
*/
public Sponsor(int code, String name)
{
this.code = code;
this.name = name;
}
/**
* Constructor with all Entity attribute values and CMR relations.
*
* @param code int value for the code property
* @param name String value for the name property
* @param trackAthlete TrackAthlete value for the trackAthlete relation
* @param grantInfos Set<GrantInfo> value for the grantInfos relation
*/
public Sponsor(int code, String name, TrackAthlete trackAthlete, Set<GrantInfo> grantInfos)
{
// 2 updatableAttributes
setCode(code);
setName(name);
// 2 relations
setTrackAthlete(trackAthlete);
setGrantInfos(grantInfos);
}
// -------- 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 Sponsor))
{
return false;
}
final Sponsor that = (Sponsor)object;
if (this.getSponsorId() == null || that.getSponsorId() == null || !this.getSponsorId().equals(that.getSponsorId()))
{
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 + (getSponsorId() == null ? 0 : getSponsorId().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("Sponsor(");
sb.append(" code=").append(getCode());
sb.append(" name=").append(getName());
sb.append(" sponsorId=").append(getSponsorId());
sb.append(" trackAthlete=").append(getTrackAthlete());
sb.append(")");
return sb.toString();
}
/**
* @see Comparable#compareTo
*/
@Override
public int compareTo(Sponsor o)
{
int cmp = 0;
if (this.getSponsorId() != null)
{
cmp = this.getSponsorId().compareTo(o.getSponsorId());
}
else
{
if (this.getName() != null)
{
cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
}
}
return cmp;
}
}