|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.elca.el4j.services.persistence.generic.dao.AbstractIdentityFixer ch.elca.el4j.services.persistence.hibernate.HibernateProxyAwareIdentityFixer
public class HibernateProxyAwareIdentityFixer
An identity fixer for objects loaded by hibernate.
Fully materialized hibernate-persisted objects (hereafter called representatives) bear the logical identity corresponding to their identity in the database; the identity fixer therefore ensures that all requests passing through this proxy yielding a representative for a given persisted object always yield the same representative.
This class considers all non-collection, non-entity types to be immutable value types. Note that lazy loading proxies are not guaranteed a unique identity by this class. This is not possible, as they are not guaranteed the proper dynamic type by hibernate.
This class assumes that entities are annotated with
Entity
, and hibernate identities are stored in exactly one
property annotated with Id
. Moreover, identity objects are required
to override equals and hashcode to provide a value comparison and must not be
identical to the object they identify.
This class needs ReflectPermission
"suppressAccessChecks" if a security manager is present and an object
requiring fixing keeps its id in a non-public field.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ch.elca.el4j.services.persistence.generic.dao.AbstractIdentityFixer |
---|
AbstractIdentityFixer.GenericInterceptor |
Field Summary |
---|
Fields inherited from class ch.elca.el4j.services.persistence.generic.dao.AbstractIdentityFixer |
---|
ANONYMOUS |
Constructor Summary | |
---|---|
HibernateProxyAwareIdentityFixer()
|
Method Summary | |
---|---|
protected Object |
id(Object o)
Returns the globally unique, logical id for the provided object, or null , if it has no id (yet), or AbstractIdentityFixer.ANONYMOUS is this
object is of value type. |
protected boolean |
immutableValue(Object o)
Returns whether the given reference represents an immutable value, either because it really is a value ( null ) or because the referenced
object's identity is not accessed and its state is not modified. |
protected boolean |
needsAdditionalProcessing(Object o)
|
protected Object |
prepareObject(Object o)
Returns the prepared Object, is called before checked for immutability to give the id fixer the chance to convert immutable values to usable ones. |
Methods inherited from class ch.elca.el4j.services.persistence.generic.dao.AbstractIdentityFixer |
---|
getChangeNotifier, getRepresentatives, instanceAccessibleObjects, instanceFields, isRepresentative, merge, merge, merge, merge, removeRepresentative, reverseMerge, reverseMerge, reverseMerge |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HibernateProxyAwareIdentityFixer()
Method Detail |
---|
protected Object id(Object o)
null
, if it has no id (yet), or AbstractIdentityFixer.ANONYMOUS
is this
object is of value type. o
may be null, point to an ordinary
object or to an array.
The ID objects returned by this method must be value-comparable using
equals
(which implies that hashCode must be overridden as well).
To permit garbage-collection, ids referring to the object they identify
should do so with weak references.
id
in class AbstractIdentityFixer
o
- The object for which a globally unique, logical id will be
returned
protected boolean immutableValue(Object o)
null
) or because the referenced
object's identity is not accessed and its state is not modified.
o
may be null, point to an ordinary object or to an array.
immutableValue
in class AbstractIdentityFixer
o
- The concerned object
True
if the given object represents an immutable
value, false
otherwiseprotected Object prepareObject(Object o)
prepareObject
in class AbstractIdentityFixer
o
- The concerned object
protected boolean needsAdditionalProcessing(Object o)
needsAdditionalProcessing
in class AbstractIdentityFixer
o
- The concerned object.
AbstractIdentityFixer.merge(T, T, boolean, java.util.IdentityHashMap, java.util.List, java.util.IdentityHashMap)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |