Car.java
// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by: hibernate/HibernateEntity.vsl in andromda-hibernate-cartridge.
//
package org.andromda.test;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
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.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
* TODO: Model Documentation for Car
*/
@Entity
@Table(name = "CAR")
// Uncomment to enable caching for Car
// @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.read-write)
@NamedQueries
({
@NamedQuery(name = "Car.findByType", query = "from Car as car where car.type = ?")
})
// HibernateEntity.vsl annotations merge-point
public abstract class Car
implements Serializable, Comparable<Car>
{
/**
* The serial version UID of this class. Needed for serialization.
*/
private static final long serialVersionUID = -7282092878573438456L;
// Generate 4 attributes
private String serial;
/**
* TODO: Model Documentation for Car.serial
* @return this.serial String
*/
@Column(name = "SERIAL", unique = true, nullable = true, insertable = true, updatable = true)
public String getSerial()
{
return this.serial;
}
/**
* TODO: Model Documentation for Car.serial
* @param serialIn String
*/
public void setSerial(String serialIn)
{
this.serial = serialIn;
}
private String name;
/**
* TODO: Model Documentation for Car.name
* @return this.name String
*/
@Column(name = "NAME", unique = true, nullable = true, insertable = true, updatable = true)
public String getName()
{
return this.name;
}
/**
* TODO: Model Documentation for Car.name
* @param nameIn String
*/
public void setName(String nameIn)
{
this.name = nameIn;
}
private CarType type;
/**
* TODO: Model Documentation for Car.type
* @return this.type CarType
*/
@Column(name = "TYPE", unique = true, nullable = true, insertable = true, updatable = true)
@Enumerated(EnumType.STRING)
public CarType getType()
{
return this.type;
}
/**
* TODO: Model Documentation for Car.type
* @param typeIn CarType
*/
public void setType(CarType typeIn)
{
this.type = typeIn;
}
private Long id;
/**
* TODO: Model Documentation for Car.id
* @return this.id Long
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID", unique = false, nullable = false, insertable = true, updatable = true)
public Long getId()
{
return this.id;
}
/**
* TODO: Model Documentation for Car.id
* @param idIn Long
*/
public void setId(Long idIn)
{
this.id = idIn;
}
// Generate 1 associations
private Person owner;
/**
* TODO: Model Documentation for Person
* @return this.owner Person
*/
@ManyToOne(optional = false, fetch = FetchType.LAZY)
@JoinColumn(name = "OWNER")
public Person getOwner()
{
return this.owner;
}
/**
* TODO: Model Documentation for Person
* @param ownerIn Person
*/
public void setOwner(Person ownerIn)
{
this.owner = ownerIn;
}
/**
* Returns true if this car is current rented.
* @return boolean
*/
public abstract boolean isRented();
/**
* Returns <code>true</code> if the argument is an Car instance and all identifiers for this entity
* equal the identifiers of the argument entity. Returns <code>false</code> otherwise.
*/
@Override
public boolean equals(Object object)
{
if (this == object)
{
return true;
}
if (!(object instanceof Car))
{
return false;
}
final Car that = (Car)object;
if (this.id == null || that.getId() == null || !this.id.equals(that.getId()))
{
return false;
}
return true;
}
/**
* Returns a hash code based on this entity's identifiers.
*/
@Override
public int hashCode()
{
int hashCode = 0;
hashCode = 29 * hashCode + (this.id == null ? 0 : this.id.hashCode());
return hashCode;
}
/**
* Constructs new instances of {@link Car}.
*/
public static final class Factory
{
/**
* Constructs a new instance of {@link Car}.
* @return new CarImpl()
*/
public static Car newInstance()
{
return new CarImpl();
}
/**
* Constructs a new instance of {@link Car}, taking all possible properties
* (except the identifier(s))as arguments.
* @param serial String
* @param name String
* @param type CarType
* @param owner Person
* @return newInstance Car
*/
public static Car newInstance(String serial, String name, CarType type, Person owner)
{
final Car entity = new CarImpl();
entity.setSerial(serial);
entity.setName(name);
entity.setType(type);
entity.setOwner(owner);
return entity;
}
}
/**
* @see Comparable#compareTo
*/
public int compareTo(Car o)
{
int cmp = 0;
if (this.getId() != null)
{
cmp = this.getId().compareTo(o.getId());
}
else
{
if (this.getSerial() != null)
{
cmp = (cmp != 0 ? cmp : this.getSerial().compareTo(o.getSerial()));
}
if (this.getName() != null)
{
cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
}
if (this.getType() != null)
{
cmp = (cmp != 0 ? cmp : this.getType().compareTo(o.getType()));
}
}
return cmp;
}
// HibernateEntity.vsl merge-point
}