Class BaseContext
java.lang.Object
org.apache.cayenne.access.DataContext
org.apache.cayenne.BaseContext
- All Implemented Interfaces:
Serializable, DataChannel, ObjectContext
Deprecated, for removal: This API element is subject to removal in a future version.
A common base superclass for Cayenne ObjectContext implementors.
- Since:
- 3.0
- See Also:
-
Field Summary
Fields inherited from class DataContext
channel, entityResolver, graphAction, mergeHandler, objectCreator, objectStore, queryCache, threadObjectContext, transactionFactory, userProperties, usingSharedSnapshotCache, validatingObjectsOnCommitModifier and TypeFieldDescriptionprotected DataChannelprotected EntityResolverprotected ObjectContextGraphActionGraph action that handles property changesprotected org.apache.cayenne.access.DataContextMergeHandlerprotected org.apache.cayenne.access.DataContextObjectCreatorprotected ObjectStoreprotected QueryCacheprotected static final ThreadLocal<ObjectContext> Deprecated, for removal: This API element is subject to removal in a future version.protected TransactionFactoryStores user defined properties associated with this DataContext.protected booleanprotected booleanFields inherited from interface DataChannel
FLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNCModifier and TypeFieldDescriptionstatic final intA synchronization type that results in changes from an ObjectContext to be recorded in the parent DataChannel.static final intA synchronization type that results in changes from an ObjectContext to be recorded in the parent DataChannel.static final EventSubjectstatic final EventSubjectstatic final EventSubjectstatic final intA synchronization type that results in cascading rollback of changes through the DataChannel stack. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDeprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Methods inherited from class DataContext
attachToChannel, attachToRuntime, attachToRuntimeIfNeeded, batchIterator, bindThreadObjectContext, clearUserProperties, commitChanges, commitChangesToParent, currentSnapshot, deletedObjects, deleteObject, deleteObjects, deleteObjects, fireDataChannelChanged, fireDataChannelCommitted, fireDataChannelRolledback, getChannel, getDelegate, getEntityResolver, getEventManager, getGraphManager, getObjectStore, getParentDataDomain, getQueryCache, getThreadObjectContext, getUserProperties, getUserProperty, hasChanges, invalidateObjects, invalidateObjects, isUsingSharedSnapshotCache, isValidatingObjectsOnCommit, iterate, iterator, localObject, modifiedObjects, newObject, newObject, newObjects, objectFromDataRow, objectFromDataRow, objectsFromDataRows, onContextFlush, onQuery, onSync, performGenericQuery, performIteratedQuery, performNonSelectingQuery, performNonSelectingQuery, performNonSelectingQuery, performQuery, performQuery, performQuery, prepareForAccess, propertyChanged, registerNewObject, removeUserProperty, rollbackChanges, rollbackChangesLocally, select, selectFirst, selectOne, setChannel, setDelegate, setEntityResolver, setQueryCache, setTransactionFactory, setUserProperty, setUsingSharedSnapshotCache, setValidatingObjectsOnCommit, uncommittedObjects, unregisterObjectsModifier and TypeMethodDescriptionprotected voidattachToChannel(DataChannel channel) Attaches to a provided DataChannel.protected voidattachToRuntime(Injector injector) Attaches this context to the CayenneRuntime whose Injector is passed as an argument to this method.protected booleanChecks whether this context is attached to Cayenne runtime stack and if not, attempts to attach itself to the runtime using Injector returned from the call toCayenneRuntime.getThreadInjector().<T> ResultBatchIterator<T> batchIterator(Select<T> query, int size) Creates a ResultBatchIterator based on the provided query and batch size.static voidbindThreadObjectContext(ObjectContext context) Deprecated, for removal: This API element is subject to removal in a future version.if you are using thread context, you can create your own ThreadLocalvoidRemoves all user-defined properties.voidSynchronizes object graph with the database.void"Flushes" the changes to the parentDataChannel.currentSnapshot(Persistent object) Returns aDataRowreflecting current, possibly uncommitted, object state.Collection<?> Returns a list of objects that are registered with this DataContext and have a statePersistenceState.DELETEDvoiddeleteObject(Object object) Schedules deletion of a persistent object.voiddeleteObjects(Collection<?> objects) Schedules deletion of a collection of persistent objects.<T> voiddeleteObjects(T... objects) Schedules deletion of one or more persistent objects.protected voidfireDataChannelChanged(Object postedBy, GraphDiff changes) protected voidfireDataChannelCommitted(Object postedBy, GraphDiff changes) protected voidfireDataChannelRolledback(Object postedBy, GraphDiff changes) Returns an DataChannel used by this context.Returns a delegate currently associated with this DataContext.Returns EntityResolver that stores all mapping information accessible by this ObjectContext.Returns EventManager associated with the ObjectStore.Returns this context's ObjectStore.Returns ObjectStore associated with this DataContext.Returns a DataDomain used by this DataContext.static ObjectContextDeprecated, for removal: This API element is subject to removal in a future version.if you are using thread context, you can create your own ThreadLocalReturns a map of user-defined properties associated with this DataContext.getUserProperty(String key) Returns a user-defined property previously set via 'setUserProperty'.booleanReturnstrueif there are any modified, deleted or new objects registered with this DataContext,falseotherwise.voidinvalidateObjects(Collection<?> objects) Invalidates a Collection of persistent objects.<T> voidinvalidateObjects(T... objects) Invalidates one or more persistent objects.booleanReturnstrueif the ObjectStore uses shared cache of a parent DataDomain.booleanReturns whether this ObjectContext performs object validation before commit is executed.<T> voiditerate(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> Performs a single database select query returning result as aResultIterator.<T extends Persistent>
TlocalObject(T objectFromAnotherContext) Returns a local copy of 'objectFromAnotherContext' object.Collection<?> Returns a list of objects that are registered with this DataContext and have a statePersistenceState.MODIFIED<T> TCreates and registers a new persistent object.Instantiates a new object and registers it with this context.Collection<?> Returns a list of objects that are registered with this DataContext and have a state PersistenceState.NEW<T extends Persistent>
TobjectFromDataRow(Class<T> objectClass, DataRow dataRow) Creates a Persistent from DataRow.objectFromDataRow(String entityName, DataRow dataRow) Creates a Persistent from DataRow.objectsFromDataRows(ClassDescriptor descriptor, List<? extends DataRow> dataRows) Converts a list of DataRows to a List of Persistent registered with this DataContext.protected GraphDiffonContextFlush(ObjectContext originatingContext, GraphDiff changes, boolean cascade) onQuery(ObjectContext context, Query query) An implementation of aDataChannelmethod that is used by child contexts to execute queries.onSync(ObjectContext originatingContext, GraphDiff changes, int syncType) Processes synchronization request from a child ObjectContext, returning a GraphDiff that describes changes to objects made on the receiving end as a result of synchronization.performGenericQuery(Query query) Executes a query returning a generic response.performIteratedQuery(Query query) Performs a single database select query returning result as aResultIterator.int[]performNonSelectingQuery(String queryName) Performs a named mapped query that does not select rows.int[]performNonSelectingQuery(String queryName, Map<String, ?> parameters) Performs a named mapped non-selecting query using a map of parameters.int[]performNonSelectingQuery(Query query) Performs a single database query that does not select rows.List<?> performQuery(String queryName, boolean expireCachedLists) Returns a list of objects or DataRows for a named query stored in one of the DataMaps.List<?> performQuery(String queryName, Map<String, ?> parameters, boolean expireCachedLists) Returns a list of objects or DataRows for a named query stored in one of the DataMaps.performQuery(Query query) Performs a single selecting query.voidprepareForAccess(Persistent object, String property, boolean lazyFaulting) A callback method that child Persistent objects are expected to call before accessing property values.voidpropertyChanged(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.voidregisterNewObject(Object object) Registers a transient object with the context, recursively registering all transient persistent objects attached to this object via relationships.voidremoveUserProperty(String key) Removes a user-defined property.voidReverts any changes that have occurred to objects registered with DataContext; also performs cascading rollback of all parent DataContexts.voidIf the parent channel is a DataContext, reverts local changes to make this context look like the parent, if the parent channel is a DataDomain, reverts all changes.<T> List<T> Executes a selecting query, returning a list of persistent objects or data rows.<T> TselectFirst(Select<T> query) Selects a single object using provided query.<T> TExecutes a selecting query, returning either NULL if query matched no objects, or a single object.voidsetChannel(DataChannel channel) Sets a new DataChannel for this context.voidsetDelegate(DataContextDelegate delegate) Sets a DataContextDelegate for this context.voidsetEntityResolver(EntityResolver entityResolver) voidsetQueryCache(QueryCache queryCache) Sets a QueryCache to be used for storing cached query results.voidsetTransactionFactory(TransactionFactory transactionFactory) Deprecated.since 4.0 avoid using this directly.voidsetUserProperty(String key, Object value) Sets a user-defined property.voidsetUsingSharedSnapshotCache(boolean flag) voidsetValidatingObjectsOnCommit(boolean flag) Sets the property defining whether this ObjectContext should perform object validation before commit is executed.Collection<?> Returns a collection of all uncommitted registered objects.voidunregisterObjects(Collection<?> objects) Unregisters a Collection of Persistent objects from the DataContext and the underlying ObjectStore.
-
Constructor Details
-
BaseContext
protected BaseContext()Deprecated, for removal: This API element is subject to removal in a future version.
-
DataContextdirectly