|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.BaseContext
org.apache.cayenne.CayenneContext
public class CayenneContext
A default generic implementation of ObjectContext suitable for accessing Cayenne from
either an ORM or a client tiers. Communicates with Cayenne via a
DataChannel
.
Field Summary |
---|
Fields inherited from class org.apache.cayenne.BaseContext |
---|
channel, entityResolver, graphAction, queryCache, threadObjectContext, userProperties, validatingObjectsOnCommit |
Fields inherited from interface org.apache.cayenne.DataChannel |
---|
FLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNC |
Constructor Summary | |
---|---|
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. |
Method Summary | ||
---|---|---|
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. |
|
ObjectContext |
createChildContext()
Creates and returns a new child ObjectContext. |
|
java.util.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. |
|
java.util.Collection<?> |
modifiedObjects()
Returns a collection of objects that are registered with this ObjectContext and have a state PersistenceState.MODIFIED |
|
|
newObject(java.lang.Class<T> persistentClass)
Creates and registers a new Persistent object instance. |
|
java.util.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. |
|
java.util.List |
performQuery(Query query)
Runs a query, returning result as list. |
|
void |
registerNewObject(java.lang.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. |
|
java.util.Collection<?> |
uncommittedObjects()
Returns a collection of MODIFIED, DELETED or NEW objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CayenneContext()
public CayenneContext(DataChannel channel)
public CayenneContext(DataChannel channel, boolean changeEventsEnabled, boolean lifecyleEventsEnabled)
Method Detail |
---|
protected void attachToChannel(DataChannel channel)
BaseContext
attachToChannel
in class BaseContext
public 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()
ObjectContext
getGraphManager
in interface ObjectContext
getGraphManager
in class BaseContext
public void commitChanges()
commitChanges
in interface ObjectContext
commitChanges
in class BaseContext
public void commitChangesToParent()
ObjectContext
ObjectContext.commitChanges()
, but no cascading flush occurs.
commitChangesToParent
in interface ObjectContext
commitChangesToParent
in class BaseContext
public void rollbackChanges()
ObjectContext
rollbackChanges
in interface ObjectContext
rollbackChanges
in class BaseContext
public void rollbackChangesLocally()
ObjectContext
ObjectContext.rollbackChanges()()
, but rollback is local to this context and no
cascading changes undoing occurs.
rollbackChangesLocally
in interface ObjectContext
rollbackChangesLocally
in class BaseContext
public <T> T newObject(java.lang.Class<T> persistentClass)
newObject
in interface ObjectContext
newObject
in class BaseContext
public void registerNewObject(java.lang.Object object)
ObjectContext
ObjectContext.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 ObjectContext
registerNewObject
in class BaseContext
object
- new object that needs to be made persistent.public java.util.List performQuery(Query query)
performQuery
in interface ObjectContext
performQuery
in class BaseContext
public QueryResponse performGenericQuery(Query query)
ObjectContext
performGenericQuery
in interface ObjectContext
performGenericQuery
in class BaseContext
public QueryResponse onQuery(ObjectContext context, Query query)
DataChannel
context
- an ObjectContext that originated the query, used to
register result objects.
public java.util.Collection<?> uncommittedObjects()
ObjectContext
uncommittedObjects
in interface ObjectContext
uncommittedObjects
in class BaseContext
public java.util.Collection<?> deletedObjects()
ObjectContext
deletedObjects
in interface ObjectContext
deletedObjects
in class BaseContext
public java.util.Collection<?> modifiedObjects()
ObjectContext
modifiedObjects
in interface ObjectContext
modifiedObjects
in class BaseContext
public java.util.Collection<?> newObjects()
ObjectContext
newObjects
in interface ObjectContext
newObjects
in class BaseContext
public ObjectContext createChildContext()
protected GraphDiff onContextFlush(ObjectContext originatingContext, GraphDiff changes, boolean cascade)
onContextFlush
in class BaseContext
public boolean hasChanges()
true
if there are any modified, deleted or new objects
registered with this CayenneContext, false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |