package com.anahata.yam.model; import java.io.Serializable; import javax.persistence.*; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; /** * The base entity model for Yam model classes. * * @author Robert Nagajek */ @MappedSuperclass @NoArgsConstructor @AllArgsConstructor @Getter public abstract class Base implements Serializable { @Id @GeneratedValue @Basic(optional = false) @Column(name = "ID", nullable = false) private Long id; @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Base other = (Base)obj; if (id == null || other.id == null) { return false; } return id.equals(other.id); } @Override public int hashCode() { if (id == null) { return super.hashCode(); } int hash = 7; hash = 97 * hash + id.hashCode(); return hash; } @Override public String toString() { return getClass().getSimpleName() + ": id=" + id + " ref=" + System.identityHashCode(this); } }