fri.util.database.jpa.commons
Class AbstractEntity

java.lang.Object
  extended by fri.util.database.jpa.commons.AbstractEntity
Direct Known Subclasses:
AbstractNestedSetsTreePojo, ClosureTableTreePojo

public abstract class AbstractEntity
extends java.lang.Object

This is an example base class for domain objects, used by unit tests. It uses the "Id" property for equals() and hashCode() implementations. This is not the best way to implement such a POJO, but sufficient for unit tests. Mind that a POJO could get lost when being inserted into a Map without having an ID (transient state), and being retrieved after it got its ID by some JPA primary key factory.

Author:
Fritz Ritzberger, 08.10.2011

Constructor Summary
AbstractEntity()
           
 
Method Summary
 boolean equals(java.lang.Object other)
           
abstract  java.io.Serializable getId()
           
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEntity

public AbstractEntity()
Method Detail

getId

public abstract java.io.Serializable getId()

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object
Returns:
true if the UID's (database primary keys) of this and the other object are defined (persistent state) and equal, else delegates to super.equals() which normally uses the object's memory address.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
the ID's hash-code (database primary key), when ID is not null (persistent state), else delegates to super.hashCode() which normally returns the object's memory address.