Package org.apache.cayenne.util
Class PersistentObjectHolder<E>
java.lang.Object
org.apache.cayenne.util.RelationshipFault<E>
org.apache.cayenne.util.PersistentObjectHolder<E>
- All Implemented Interfaces:
Serializable
,ValueHolder<E>
A ValueHolder implementation that holds a single Persistent object related to an object
used to initialize PersistentObjectHolder. Value is resolved on first access.
- Since:
- 1.2
- See Also:
-
Field Summary
Fields inherited from class org.apache.cayenne.util.RelationshipFault
relationshipName, relationshipOwner
-
Constructor Summary
ConstructorDescriptionPersistentObjectHolder
(Persistent relationshipOwner, String relationshipName) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
connect
(Persistent persistent) Returns an object that should be stored as a value in this ValueHolder, ensuring that it is registered with the same context.getValue()
Returns a value resolving it via a query on the first call to this method.Retrieves ValueHolder value without triggering fault resolution.void
Turns a ValueHolder into a fault.boolean
isFault()
Returns true if this holder is not resolved, meaning its object is not yet known.protected void
mergeLocalChanges
(List resolved) protected void
resolve()
Reads an object from the database.Sets an object value, marking this ValueHolder as resolved.setValueDirectly
(E value) Sets ValueHolder vaue without triggering fault resolution.Methods inherited from class org.apache.cayenne.util.RelationshipFault
getRelationshipName, getRelationshipOwner, isTransientParent, isUncommittedParent, resolveFromDB, updateReverse
-
Field Details
-
fault
protected boolean fault -
value
-
-
Constructor Details
-
PersistentObjectHolder
-
-
Method Details
-
isFault
public boolean isFault()Returns true if this holder is not resolved, meaning its object is not yet known.- Specified by:
isFault
in interfaceValueHolder<E>
-
invalidate
public void invalidate()Description copied from interface:ValueHolder
Turns a ValueHolder into a fault.- Specified by:
invalidate
in interfaceValueHolder<E>
-
getValue
Returns a value resolving it via a query on the first call to this method.- Specified by:
getValue
in interfaceValueHolder<E>
- Throws:
CayenneRuntimeException
-
getValueDirectly
Description copied from interface:ValueHolder
Retrieves ValueHolder value without triggering fault resolution.- Specified by:
getValueDirectly
in interfaceValueHolder<E>
- Throws:
CayenneRuntimeException
-
setValue
Sets an object value, marking this ValueHolder as resolved.- Specified by:
setValue
in interfaceValueHolder<E>
- Parameters:
value
- a new value of the ValueHolder.- Returns:
- a previous value saved in the ValueHolder.
- Throws:
CayenneRuntimeException
-
setValueDirectly
Description copied from interface:ValueHolder
Sets ValueHolder vaue without triggering fault resolution.- Specified by:
setValueDirectly
in interfaceValueHolder<E>
- Throws:
CayenneRuntimeException
-
connect
Returns an object that should be stored as a value in this ValueHolder, ensuring that it is registered with the same context. -
resolve
protected void resolve()Reads an object from the database. -
mergeLocalChanges
- Specified by:
mergeLocalChanges
in classRelationshipFault<E>
-