|
||||||||||
| 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 | |
|---|---|
protected EntityResolver |
entityResolver
|
| Fields inherited from class org.apache.cayenne.BaseContext |
|---|
channel, queryCache, threadObjectContext |
| 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 syncEventsEnabled)
Creates a new CayenneContext, initializing it with a channel. |
|
| Method Summary | ||
|---|---|---|
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 |
|
void |
deleteObject(Object object)
Deletes an object locally, scheduling it for future deletion from the external data store. |
|
EntityResolver |
getEntityResolver()
Returns an EntityResolver that provides mapping information needed for CayenneContext operation. |
|
GraphManager |
getGraphManager()
Returns GraphManager that manages object graph associated with this context. |
|
boolean |
isChangeEventsEnabled()
Returns true if this context posts individual object modification events. |
|
boolean |
isLifecycleEventsEnabled()
Returns true if this context posts lifecycle events. |
|
Persistent |
localObject(ObjectId id,
Object prototype)
Converts a list of Persistent objects registered in some other ObjectContext to a list of objects local to this ObjectContext. |
|
Collection<?> |
modifiedObjects()
Returns a collection of objects that are registered with this ObjectContext and have a state PersistenceState.MODIFIED |
|
|
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 |
|
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 |
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. |
|
void |
setChannel(DataChannel channel)
Sets the context channel, setting up a listener for channel events. |
|
void |
setEntityResolver(EntityResolver entityResolver)
|
|
Collection<?> |
uncommittedObjects()
Returns a collection of MODIFIED, DELETED or NEW objects. |
|
| Methods inherited from class org.apache.cayenne.BaseContext |
|---|
bindThreadObjectContext, getChannel, getQueryCache, getThreadObjectContext, prepareForAccess, prepareForAccess, setQueryCache |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected EntityResolver entityResolver
| Constructor Detail |
|---|
public CayenneContext()
public CayenneContext(DataChannel channel)
public CayenneContext(DataChannel channel,
boolean changeEventsEnabled,
boolean syncEventsEnabled)
graphEventsEnabled is true, this context will broadcast GraphEvents
using ObjectContext.GRAPH_CHANGE_SUBJECT.
| Method Detail |
|---|
public void setChannel(DataChannel channel)
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 EntityResolver getEntityResolver()
getEntityResolver in interface ObjectContextgetEntityResolver in class BaseContextpublic void setEntityResolver(EntityResolver entityResolver)
public GraphManager getGraphManager()
ObjectContext
getGraphManager 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()
ObjectContext
rollbackChanges 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 void deleteObject(Object object)
deleteObject in interface ObjectContextdeleteObject 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)
ObjectContext
performGenericQuery in interface ObjectContextperformGenericQuery in class BaseContext
public Persistent localObject(ObjectId id,
Object prototype)
Current limitation: all objects in the source list must be either in COMMITTED or in HOLLOW state.
localObject in interface ObjectContextlocalObject in class BaseContext
public void propertyChanged(Persistent object,
String property,
Object oldValue,
Object newValue)
ObjectContext
propertyChanged in interface ObjectContextpropertyChanged in class BaseContextpublic Collection<?> uncommittedObjects()
ObjectContext
uncommittedObjects in interface ObjectContextuncommittedObjects in class BaseContextpublic Collection<?> deletedObjects()
ObjectContext
deletedObjects in interface ObjectContextdeletedObjects in class BaseContextpublic Collection<?> modifiedObjects()
ObjectContext
modifiedObjects in interface ObjectContextmodifiedObjects in class BaseContextpublic Collection<?> newObjects()
ObjectContext
newObjects in interface ObjectContextnewObjects in class BaseContext
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||