UserRole.java
// 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 12:09:10.
//
package org.andromda.timetracker.domain;
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.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
/**
* <p>
* TODO: Model Documentation for org.andromda.timetracker.domain.UserRole
* </p>
*
* Autogenerated POJO EJB class for UserRole containing the
* bulk of the entity implementation.
*
* This is autogenerated by AndroMDA using the EJB3
* cartridge.
*
* DO NOT MODIFY this class.
*/
@Entity
@Table(name="USER_ROLE")
@NamedQuery(name="UserRole.findAll", query="SELECT u FROM UserRole AS u")
public class UserRole
implements Serializable, Comparable<UserRole>{
private static final long serialVersionUID = 5242293720261134094L;
// ----------- 2 Attribute Definitions ------------
protected Role role;
protected Long userRoleId;
// -------- 2 Attribute Accessors ----------
/**
* <p>
* TODO: Model Documentation for role
* </p>
* Get the role property.
* @return Role The value of role
*/
@Column(name="ROLE", nullable=false, insertable=true, updatable=true, columnDefinition="VARCHAR(20)")
@Enumerated(EnumType.STRING)
@NotNull(message="role is required")
public Role getRole()
{
return this.role;
}
/**
* <p>
* TODO: Model Documentation for role
* </p>
* Set the role property.
* @param value the new value
*/
public void setRole(Role value)
{
this.role = value;
}
/**
* <p>
* TODO: Model Documentation for userRoleId
* </p>
* Get the userRoleId property.
* @return Long The value of userRoleId
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="USER_ROLE_ID", nullable=false, insertable=true, updatable=true)
public Long getUserRoleId()
{
return this.userRoleId;
}
/**
* <p>
* TODO: Model Documentation for userRoleId
* </p>
* Set the userRoleId property.
* @param value the new value
*/
public void setUserRoleId(Long value)
{
this.userRoleId = value;
}
// ------------- 0 Relations ------------------
// --------------- Constructors -----------------
/**
* Default empty no-arg constructor
*/
public UserRole()
{
// Default empty constructor
}
/**
* Constructor with all updatable Entity attributes except auto incremented identifiers.
*
* @param role Role value for the role property required=true lower=1
*/
public UserRole(Role role)
{
this.role = role;
}
// -------- 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 UserRole))
{
return false;
}
final UserRole that = (UserRole)object;
if (this.getUserRoleId() == null || that.getUserRoleId() == null || !this.getUserRoleId().equals(that.getUserRoleId()))
{
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 + (getUserRoleId() == null ? 0 : getUserRoleId().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("UserRole(");
sb.append(" role=").append(getRole());
sb.append(" userRoleId=").append(getUserRoleId());
sb.append(")");
return sb.toString();
}
/**
* @see Comparable#compareTo
*/
@Override
public int compareTo(UserRole o)
{
int cmp = 0;
if (this.getUserRoleId() != null)
{
cmp = this.getUserRoleId().compareTo(o.getUserRoleId());
}
else
{
if (this.getRole() != null)
{
cmp = (cmp != 0 ? cmp : this.getRole().compareTo(o.getRole()));
}
}
return cmp;
}
}