|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.riotfamily.common.beans.config.ConfigurableBean
org.riotfamily.riot.hibernate.domain.ActiveRecord
org.riotfamily.riot.hibernate.domain.ActiveRecordSupport
public abstract class ActiveRecordSupport
Abstract base class for ActiveRecord
s with a Long
generated identifier. The class is Serializable
and provides default
implementations for both hashCode()
and
equals()
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.riotfamily.riot.hibernate.domain.ActiveRecord |
---|
ActiveRecord.ForEachCallback<T> |
Constructor Summary | |
---|---|
ActiveRecordSupport()
|
Method Summary | |
---|---|
boolean |
equals(Object obj)
Generic implementation that first checks for object identity. |
Long |
getId()
Returns the identifier of this persistent instance. |
int |
hashCode()
Default implementation that always returns 0 . |
void |
setId(Long id)
Sets the identifier of this persistent instance. |
String |
toString()
Generic implementation that returns a String with the pattern <className>#<id> for persistent objects, or
<className>@<identityHashCode> if the instance
is unsaved. |
Methods inherited from class org.riotfamily.riot.hibernate.domain.ActiveRecord |
---|
createQuery, delete, find, forEach, getSession, getSessionFactory, load, load, lock, merge, save, update |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ActiveRecordSupport()
Method Detail |
---|
public Long getId()
public void setId(Long id)
id
- an identifierpublic int hashCode()
0
. This
implementation is very inefficient for large collections as all instances
will end up in the same hash bucket. Yet this is the only safe
generic implementation, as it guarantees that the hashCode does not
change while the object is contained in a collection.
If you plan to put your entities into large HashSets or HashMaps, you should consider to overwrite this method and implement it based on an immutable business key.
If your entities don't have such an immutable key you can use the id property instead, but keep in mind that collections won't be intact if you save a transient object after adding it to a set or map.
hashCode
in class Object
http://www.hibernate.org/109.html
public boolean equals(Object obj)
Hibernate#getClass(Object))
for both objects and checks if the
classes are the same.
equals
in class Object
public String toString()
<className>#<id>
for persistent objects, or
<className>@<identityHashCode>
if the instance
is unsaved.
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |