public class CayenneContext extends BaseContext
DataChannel.channel, entityResolver, graphAction, queryCache, threadObjectContext, userProperties, validatingObjectsOnCommitFLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNC| Constructor and Description |
|---|
CayenneContext()
Creates a new CayenneContext with no channel and disabled graph events.
|
CayenneContext(DataChannel channel)
Creates a new CayenneContext, initializing it with a channel instance.
|
CayenneContext(DataChannel channel,
boolean changeEventsEnabled,
boolean lifecyleEventsEnabled)
Creates a new CayenneContext, initializing it with a channel.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
attachToChannel(DataChannel channel)
Attaches to a provided DataChannel.
|
void |
commitChanges()
Commits changes to uncommitted objects.
|
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
|
GraphManager |
getGraphManager()
Returns GraphManager that manages object graph associated with this
context.
|
boolean |
hasChanges()
Returns
true if there are any modified, deleted or new
objects registered with this CayenneContext, false
otherwise. |
boolean |
isChangeEventsEnabled()
Returns true if this context posts individual object modification events.
|
boolean |
isLifecycleEventsEnabled()
Returns true if this context posts lifecycle events.
|
<T> ResultIterator<T> |
iterator(Select<T> query)
This method simply returns an iterator over a list of selected objects.
|
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 and registers a new Persistent object instance.
|
Collection<?> |
newObjects()
Returns a collection of objects that are registered with this
ObjectContext and have a state PersistenceState.NEW
|
protected GraphDiff |
onContextFlush(ObjectContext originatingContext,
GraphDiff changes,
boolean cascade) |
QueryResponse |
onQuery(ObjectContext context,
Query query)
Executes a query, using provided context to register persistent objects if
query returns any objects.
|
QueryResponse |
performGenericQuery(Query query)
Executes any kind of query providing the result in a form of
QueryResponse.
|
List |
performQuery(Query query)
Runs a query, returning result as list.
|
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.
|
Collection<?> |
uncommittedObjects()
Returns a collection of MODIFIED, DELETED or NEW objects.
|
attachToRuntime, attachToRuntimeIfNeeded, batchIterator, bindThreadObjectContext, deleteObject, deleteObjects, deleteObjects, fireDataChannelChanged, fireDataChannelCommitted, fireDataChannelRolledback, getChannel, getEntityResolver, getEventManager, getQueryCache, getThreadObjectContext, getUserProperties, getUserProperty, injectInitialValue, invalidateObjects, invalidateObjects, isValidatingObjectsOnCommit, iterate, localObject, onSync, prepareForAccess, propertyChanged, select, selectFirst, selectOne, setChannel, setEntityResolver, setQueryCache, setUserProperty, setValidatingObjectsOnCommitpublic CayenneContext()
public CayenneContext(DataChannel channel)
public CayenneContext(DataChannel channel, boolean changeEventsEnabled, boolean lifecyleEventsEnabled)
protected void attachToChannel(DataChannel channel)
BaseContextattachToChannel in class BaseContextpublic boolean isChangeEventsEnabled()
ObjectContext.GRAPH_CHANGED_SUBJECT.public boolean isLifecycleEventsEnabled()
ObjectContext.GRAPH_COMMIT_STARTED_SUBJECT, ObjectContext.GRAPH_COMMITTED_SUBJECT,
ObjectContext.GRAPH_COMMIT_ABORTED_SUBJECT, ObjectContext.GRAPH_ROLLEDBACK_SUBJECT.
.public GraphManager getGraphManager()
ObjectContextgetGraphManager in interface ObjectContextgetGraphManager in class BaseContextpublic void commitChanges()
commitChanges in interface ObjectContextcommitChanges in class BaseContextpublic void commitChangesToParent()
ObjectContextObjectContext.commitChanges(), but no cascading flush occurs.commitChangesToParent in interface ObjectContextcommitChangesToParent in class BaseContextpublic void rollbackChanges()
ObjectContextrollbackChanges in interface ObjectContextrollbackChanges in class BaseContextpublic void rollbackChangesLocally()
ObjectContextObjectContext.rollbackChanges(), but rollback is local to this
context and no cascading changes undoing occurs.rollbackChangesLocally in interface ObjectContextrollbackChangesLocally in class BaseContextpublic <T> T newObject(Class<T> persistentClass)
newObject in interface ObjectContextnewObject in class BaseContextpublic void registerNewObject(Object object)
ObjectContextObjectContext.newObject(Class) is that a user creates an object herself,
before attaching it to the context, instead of relying on Cayenne to do
that.registerNewObject in interface ObjectContextregisterNewObject in class BaseContextobject - new object that needs to be made persistent.public List performQuery(Query query)
performQuery in interface ObjectContextperformQuery in class BaseContextpublic QueryResponse performGenericQuery(Query query)
ObjectContextperformGenericQuery in interface ObjectContextperformGenericQuery in class BaseContextpublic QueryResponse onQuery(ObjectContext context, Query query)
DataChannelcontext - an ObjectContext that originated the query, used to
register result objects.public Collection<?> uncommittedObjects()
ObjectContextuncommittedObjects in interface ObjectContextuncommittedObjects in class BaseContextpublic Collection<?> deletedObjects()
ObjectContextdeletedObjects in interface ObjectContextdeletedObjects in class BaseContextpublic Collection<?> modifiedObjects()
ObjectContextmodifiedObjects in interface ObjectContextmodifiedObjects in class BaseContextpublic Collection<?> newObjects()
ObjectContextnewObjects in interface ObjectContextnewObjects in class BaseContextprotected GraphDiff onContextFlush(ObjectContext originatingContext, GraphDiff changes, boolean cascade)
onContextFlush in class BaseContextpublic boolean hasChanges()
true if there are any modified, deleted or new
objects registered with this CayenneContext, false
otherwise.public <T> ResultIterator<T> iterator(Select<T> query)
iterator in interface ObjectContextiterator in class BaseContextCopyright © 2001–2023 Apache Cayenne. All rights reserved.