org.jlot.hibernate.orm.PersistableEntity Maven / Gradle / Ivy
The newest version!
package org.jlot.hibernate.orm;
import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public class PersistableEntity implements Serializable, Comparable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Integer id;
public Integer getId ( )
{
return id;
}
public boolean isNew ( )
{
return getId() == null;
}
@Override
public int compareTo ( PersistableEntity otherPersistableEntity )
{
return getId().compareTo(otherPersistableEntity.getId());
}
}