public interface ObjectContext extends DataChannel, Serializable
FLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNC| Modifier and Type | Method and Description | 
|---|---|
| <T> ResultBatchIterator<T> | batchIterator(Select<T> query,
             int size)Creates a ResultBatchIterator based on the provided query and batch size. | 
| void | commitChanges()Flushes all changes to objects in this context to the parent DataChannel,
 cascading flush operation all the way through the stack, ultimately
 saving data in the database. | 
| void | commitChangesToParent()Flushes all changes to objects in this context to the parent DataChannel. | 
| Collection<?> | deletedObjects()Returns a collection of objects that are registered with this
 ObjectContext and have a state PersistenceState.DELETED | 
| void | deleteObject(Object object)Schedules deletion of a persistent object. | 
| void | deleteObjects(Collection<?> objects)Schedules deletion of a collection of persistent objects. | 
| <T> void | deleteObjects(T... objects)Schedules deletion of one or more persistent objects. | 
| DataChannel | getChannel()Returns an DataChannel used by this context. | 
| EntityResolver | getEntityResolver()Returns EntityResolver that stores all mapping information accessible by
 this ObjectContext. | 
| GraphManager | getGraphManager()Returns GraphManager that manages object graph associated with this
 context. | 
| Object | getUserProperty(String key)Returns a user-defined property previously set via 'setUserProperty'. | 
| boolean | hasChanges()Returns  trueif there are any modified, deleted or new
 objects registered with this ObjectContext,falseotherwise. | 
| void | invalidateObjects(Collection<?> objects)Invalidates a Collection of persistent objects. | 
| <T> void | invalidateObjects(T... objects)Invalidates one or more persistent objects. | 
| <T> void | iterate(Select<T> query,
       ResultIteratorCallback<T> callback)Creates a ResultIterator based on the provided query and passes it to a
 callback for processing. | 
| <T> ResultIterator<T> | iterator(Select<T> query)Creates a ResultIterator based on the provided query. | 
| <T extends Persistent> | localObject(T objectFromAnotherContext)Returns a local copy of 'objectFromAnotherContext' object. | 
| Collection<?> | modifiedObjects()Returns a collection of objects that are registered with this
 ObjectContext and have a state PersistenceState.MODIFIED | 
| <T> T | newObject(Class<T> persistentClass)Creates a new persistent object of a given class scheduled to be inserted
 to the database on next commit. | 
| Collection<?> | newObjects()Returns a collection of objects that are registered with this
 ObjectContext and have a state PersistenceState.NEW | 
| QueryResponse | performGenericQuery(Query query)Executes any kind of query providing the result in a form of
 QueryResponse. | 
| List | performQuery(Query query)Executes a selecting query, returning a list of persistent objects or
 data rows. | 
| void | prepareForAccess(Persistent object,
                String property,
                boolean lazyFaulting)A callback method that child Persistent objects are expected to call
 before accessing property values. | 
| void | propertyChanged(Persistent object,
               String property,
               Object oldValue,
               Object newValue)A callback method that child Persistent objects are expected to call from
 inside the setter after modifying a value of a persistent property,
 including "simple" and "arc" properties. | 
| void | registerNewObject(Object object)Registers a transient object with the context. | 
| void | rollbackChanges()Resets all uncommitted changes made to the objects in this ObjectContext,
 cascading rollback operation all the way through the stack. | 
| void | rollbackChangesLocally()Resets all uncommitted changes made to the objects in this ObjectContext. | 
| <T> List<T> | select(Select<T> query)Executes a selecting query, returning a list of persistent objects or
 data rows. | 
| <T> T | selectFirst(Select<T> query)Selects a single object using provided query. | 
| <T> T | selectOne(Select<T> query)Executes a selecting query, returning either NULL if query matched no
 objects, or a single object. | 
| void | setUserProperty(String key,
               Object value)Sets a user-defined property. | 
| Collection<?> | uncommittedObjects()Returns a collection of MODIFIED, DELETED or NEW objects. | 
getEventManager, onQuery, onSyncEntityResolver getEntityResolver()
getEntityResolver in interface DataChannelCollection<?> newObjects()
Collection<?> deletedObjects()
Collection<?> modifiedObjects()
Collection<?> uncommittedObjects()
<T extends Persistent> T localObject(T objectFromAnotherContext)
Note that passing an object with a non-existing id, may later result in FaultFailureException on attempt to read returned object properties.
<T> T newObject(Class<T> persistentClass)
void registerNewObject(Object object)
newObject(Class) is that a user creates an object herself,
 before attaching it to the context, instead of relying on Cayenne to do
 that.object - new object that needs to be made persistent.void deleteObject(Object object) throws DeleteDenyException
DeleteDenyException - if a DeleteRule.DENY delete
             rule is applicable for object deletion.void deleteObjects(Collection<?> objects) throws DeleteDenyException
DeleteDenyException - if a DeleteRule.DENY delete
             rule is applicable for object deletion.<T> void deleteObjects(T... objects)
                throws DeleteDenyException
deleteObjects(Collection) only with a vararg argument list for
 easier deletion of individual objects.DeleteDenyException - if a DeleteRule.DENY delete
             rule is applicable for object deletion.void prepareForAccess(Persistent object, String property, boolean lazyFaulting)
void propertyChanged(Persistent object, String property, Object oldValue, Object newValue)
void commitChanges()
void commitChangesToParent()
commitChanges(), but no cascading flush occurs.void rollbackChanges()
void rollbackChangesLocally()
rollbackChanges(), but rollback is local to this
 context and no cascading changes undoing occurs.List performQuery(Query query)
<T> List<T> select(Select<T> query)
<T> T selectOne(Select<T> query)
CayenneRuntimeException is thrown.<T> T selectFirst(Select<T> query)
 If it matched more than one object, the first object from the list is
 returned. This makes 'selectFirst' different from
 selectOne(Select), which would throw in this situation.
 'selectFirst' is useful e.g. when the query is ordered and we only want
 to see the first object (e.g. "most recent news article"), etc.
 
Selecting the first object via "Select.selectFirst(ObjectContext)" is more comprehensible than selecting via "ObjectContext.selectFirst(Select)", because implementations of "Select" set fetch size limit to one.
<T> void iterate(Select<T> query, ResultIteratorCallback<T> callback)
<T> ResultIterator<T> iterator(Select<T> query)
iterate(Select, ResultIteratorCallback) as an alternative.<T> ResultBatchIterator<T> batchIterator(Select<T> query, int size)
QueryResponse performGenericQuery(Query query)
GraphManager getGraphManager()
DataChannel getChannel()
boolean hasChanges()
true if there are any modified, deleted or new
 objects registered with this ObjectContext, false otherwise.void invalidateObjects(Collection<?> objects)
<T> void invalidateObjects(T... objects)
invalidateObjects(Collection) only with a vararg argument list
 for easier invalidation of individual objects. If no arguments are passed
 to this method, it does nothing.Object getUserProperty(String key)
Copyright © 2001–2023 Apache Cayenne. All rights reserved.