Employee.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:03.
//
package org.andromda.demo.ejb3.employee;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
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.employee.Employee
* </p>
*
* Autogenerated POJO EJB class for Employee containing the
* bulk of the entity implementation.
*
* This is autogenerated by AndroMDA using the EJB3
* cartridge.
*
* DO NOT MODIFY this class.
*/
@Entity
@Table(name="EMPLOYEE")
@NamedQueries
({
@NamedQuery(name="Employee.findAll", query="SELECT e FROM Employee AS e"),
@NamedQuery(name="Employee.findByContractType", query="SELECT e from Employee as e WHERE e.contractType = :contractType"),
@NamedQuery(name="Employee.findByDepartmentCode", query="SELECT e from Employee as e WHERE e.departmentCode = :departmentCode")
})
public class Employee
implements Serializable, Comparable<Employee>{
private static final long serialVersionUID = 4564698198484528444L;
// ----------- 4 Attribute Definitions ------------
protected Integer id;
protected String name;
protected EmployeeContractType contractType;
protected EmployeeDeptCode departmentCode;
// -------- 4 Attribute Accessors ----------
/**
* <p>
* TODO: Model Documentation for id
* </p>
* Get the id property.
* @return Integer The value of id
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID", nullable=false, insertable=true, updatable=true)
public Integer getId()
{
return this.id;
}
/**
* <p>
* TODO: Model Documentation for id
* </p>
* Set the id property.
* @param value the new value
*/
public void setId(Integer value)
{
this.id = 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;
}
/**
* <p>
* TODO: Model Documentation for contractType
* </p>
* Get the contractType property.
* @return EmployeeContractType The value of contractType
*/
@Column(name="CONTRACT_TYPE", nullable=false, insertable=true, updatable=true, columnDefinition="VARCHAR(20)")
@Enumerated(EnumType.STRING)
@NotNull(message="contractType is required")
public EmployeeContractType getContractType()
{
return this.contractType;
}
/**
* <p>
* TODO: Model Documentation for contractType
* </p>
* Set the contractType property.
* @param value the new value
*/
public void setContractType(EmployeeContractType value)
{
this.contractType = value;
}
/**
* <p>
* TODO: Model Documentation for departmentCode
* </p>
* Get the departmentCode property.
* @return EmployeeDeptCode The value of departmentCode
*/
@Column(name="DEPARTMENT_CODE", nullable=false, insertable=true, updatable=true)
@NotNull(message="departmentCode is required")
public EmployeeDeptCode getDepartmentCode()
{
return this.departmentCode;
}
/**
* <p>
* TODO: Model Documentation for departmentCode
* </p>
* Set the departmentCode property.
* @param value the new value
*/
public void setDepartmentCode(EmployeeDeptCode value)
{
this.departmentCode = value;
}
// ------------- 0 Relations ------------------
// --------------- Constructors -----------------
/**
* Default empty no-arg constructor
*/
public Employee()
{
// 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 contractType EmployeeContractType value for the contractType property required=true lower=1
* @param departmentCode EmployeeDeptCode value for the departmentCode property required=true lower=1
*/
public Employee(String name, EmployeeContractType contractType, EmployeeDeptCode departmentCode)
{
this.name = name;
this.contractType = contractType;
this.departmentCode = departmentCode;
}
// -------- 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 Employee))
{
return false;
}
final Employee that = (Employee)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("Employee(");
sb.append(" id=").append(getId());
sb.append(" name=").append(getName());
sb.append(" contractType=").append(getContractType());
sb.append(" departmentCode=").append(getDepartmentCode());
sb.append(")");
return sb.toString();
}
/**
* @see Comparable#compareTo
*/
@Override
public int compareTo(Employee 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.getContractType() != null)
{
cmp = (cmp != 0 ? cmp : this.getContractType().compareTo(o.getContractType()));
}
if (this.getDepartmentCode() != null)
{
cmp = (cmp != 0 ? cmp : this.getDepartmentCode().compareTo(o.getDepartmentCode()));
}
}
return cmp;
}
}