net.dontdrinkandroot.persistence.entity
Class AbstractEntity<K>

java.lang.Object
  extended by net.dontdrinkandroot.persistence.entity.AbstractEntity<K>
Type Parameters:
K - Type of the primary key.
All Implemented Interfaces:
java.io.Serializable, Entity<K>
Direct Known Subclasses:
AbstractGeneratedIdEntity, AbstractIdEntity, GeneratedLongIdEntity, LongIdEntity

@MappedSuperclass
public abstract class AbstractEntity<K>
extends java.lang.Object
implements Entity<K>

Represents an entity with a primary key. The method getId() must be implemented, even if the primary key has a different field name, also make sure that the primary key implements equals/hashcode correctly. hashCode() and equals() are based on the id, so make sure not to use the in any context where these methods are important while no id is set (e.g. in HashMaps).

Author:
Philip W. Sorst
See Also:
Serialized Form

Constructor Summary
AbstractEntity()
          Constructs an entity without the primary key being set.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.dontdrinkandroot.persistence.entity.Entity
getId
 

Constructor Detail

AbstractEntity

public AbstractEntity()
Constructs an entity without the primary key being set.

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2013 dontdrinkandroot. All Rights Reserved.