BaseContext (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne, class: BaseContext

# Class BaseContext

java.lang.Object
org.apache.cayenne.access.DataContext
org.apache.cayenne.BaseContext

All Implemented Interfaces:
  `Serializable, DataChannel, ObjectContext`

@Deprecated(since="5.0", forRemoval=true) public abstract class BaseContext extends DataContext
Deprecated, for removal: This API element is subject to removal in a future version.
since 5.0, use `DataContext` directly
A common base superclass for Cayenne ObjectContext implementors.

Since:
  3.0
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class DataContext

  `channel, entityResolver, graphAction, mergeHandler, objectCreator, objectStore, queryCache, threadObjectContext, transactionFactory, userProperties, usingSharedSnapshotCache, validatingObjectsOnCommit`
  Modifier and Type
  Field
  Description
  `protected DataChannel`
  `channel`
  `protected EntityResolver`
  `entityResolver`
  `protected ObjectContextGraphAction`
  `graphAction`
  Graph action that handles property changes
  `protected org.apache.cayenne.access.DataContextMergeHandler`
  `mergeHandler`
  `protected org.apache.cayenne.access.DataContextObjectCreator`
  `objectCreator`
  `protected ObjectStore`
  `objectStore`
  `protected QueryCache`
  `queryCache`
  `protected static final ThreadLocal<ObjectContext>`
  `threadObjectContext`
  Deprecated, for removal: This API element is subject to removal in a future version.
  `protected TransactionFactory`
  `transactionFactory`
  `protected Map<String,Object>`
  `userProperties`
  Stores user defined properties associated with this DataContext.
  `protected boolean`
  `usingSharedSnapshotCache`
  `protected boolean`
  `validatingObjectsOnCommit`

  ### Fields inherited from interface DataChannel

  `FLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNC`
  Modifier and Type
  Field
  Description
  `static final int`
  `FLUSH_CASCADE_SYNC`
  A synchronization type that results in changes from an ObjectContext to be recorded in the parent DataChannel.
  `static final int`
  `FLUSH_NOCASCADE_SYNC`
  A synchronization type that results in changes from an ObjectContext to be recorded in the parent DataChannel.
  `static final EventSubject`
  `GRAPH_CHANGED_SUBJECT`
  `static final EventSubject`
  `GRAPH_FLUSHED_SUBJECT`
  `static final EventSubject`
  `GRAPH_ROLLEDBACK_SUBJECT`
  `static final int`
  `ROLLBACK_CASCADE_SYNC`
  A synchronization type that results in cascading rollback of changes through the DataChannel stack.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `BaseContext()`
  Deprecated, 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, unregisterObjects`
  Modifier and Type
  Method
  Description
  `protected void`
  `attachToChannel(DataChannel channel)`
  Attaches to a provided DataChannel.
  `protected void`
  `attachToRuntime(Injector injector)`
  Attaches this context to the CayenneRuntime whose Injector is passed as an argument to this method.
  `protected boolean`
  `attachToRuntimeIfNeeded()`
  Checks 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 to `CayenneRuntime.getThreadInjector()`.
  `<T> ResultBatchIterator<T>`
  `batchIterator(Select<T> query, int size)`
  Creates a ResultBatchIterator based on the provided query and batch size.
  `static void`
  `bindThreadObjectContext(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 ThreadLocal
  `void`
  `clearUserProperties()`
  Removes all user-defined properties.
  `void`
  `commitChanges()`
  Synchronizes object graph with the database.
  `void`
  `commitChangesToParent()`
  "Flushes" the changes to the parent `DataChannel`.
  `DataRow`
  `currentSnapshot(Persistent object)`
  Returns a `DataRow` reflecting current, possibly uncommitted, object state.
  `Collection<?>`
  `deletedObjects()`
  Returns a list of objects that are registered with this DataContext 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.
  `protected void`
  `fireDataChannelChanged(Object postedBy, GraphDiff changes)`
  `protected void`
  `fireDataChannelCommitted(Object postedBy, GraphDiff changes)`
  `protected void`
  `fireDataChannelRolledback(Object postedBy, GraphDiff changes)`
  `DataChannel`
  `getChannel()`
  Returns an DataChannel used by this context.
  `DataContextDelegate`
  `getDelegate()`
  Returns a delegate currently associated with this DataContext.
  `EntityResolver`
  `getEntityResolver()`
  Returns EntityResolver that stores all mapping information accessible by this ObjectContext.
  `EventManager`
  `getEventManager()`
  Returns EventManager associated with the ObjectStore.
  `GraphManager`
  `getGraphManager()`
  Returns this context's ObjectStore.
  `ObjectStore`
  `getObjectStore()`
  Returns ObjectStore associated with this DataContext.
  `DataDomain`
  `getParentDataDomain()`
  Returns a DataDomain used by this DataContext.
  `QueryCache`
  `getQueryCache()`
  `static ObjectContext`
  `getThreadObjectContext()`
  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 ThreadLocal
  `protected Map<String,Object>`
  `getUserProperties()`
  Returns a map of user-defined properties associated with this DataContext.
  `Object`
  `getUserProperty(String key)`
  Returns a user-defined property previously set via 'setUserProperty'.
  `boolean`
  `hasChanges()`
  Returns `true` if there are any modified, deleted or new objects registered with this DataContext, `false` otherwise.
  `void`
  `invalidateObjects(Collection<?> objects)`
  Invalidates a Collection of persistent objects.
  `<T> void`
  `invalidateObjects(T... objects)`
  Invalidates one or more persistent objects.
  `boolean`
  `isUsingSharedSnapshotCache()`
  Returns `true` if the ObjectStore uses shared cache of a parent DataDomain.
  `boolean`
  `isValidatingObjectsOnCommit()`
  Returns whether this ObjectContext performs object validation before commit is executed.
  `<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)`
  Performs a single database select query returning result as a `ResultIterator`.
  `<T extends Persistent>
  T`
  `localObject(T objectFromAnotherContext)`
  Returns a local copy of 'objectFromAnotherContext' object.
  `Collection<?>`
  `modifiedObjects()`
  Returns a list of objects that are registered with this DataContext and have a state `PersistenceState.MODIFIED`
  `<T> T`
  `newObject(Class<T> persistentClass)`
  Creates and registers a new persistent object.
  `Persistent`
  `newObject(String entityName)`
  Instantiates a new object and registers it with this context.
  `Collection<?>`
  `newObjects()`
  Returns a list of objects that are registered with this DataContext and have a state PersistenceState.NEW
  `<T extends Persistent>
  T`
  `objectFromDataRow(Class<T> objectClass, DataRow dataRow)`
  Creates a Persistent from DataRow.
  `Persistent`
  `objectFromDataRow(String entityName, DataRow dataRow)`
  Creates a Persistent from DataRow.
  `List`
  `objectsFromDataRows(ClassDescriptor descriptor, List<? extends DataRow> dataRows)`
  Converts a list of DataRows to a List of Persistent registered with this DataContext.
  `protected GraphDiff`
  `onContextFlush(ObjectContext originatingContext, GraphDiff changes, boolean cascade)`
  `QueryResponse`
  `onQuery(ObjectContext context, Query query)`
  An implementation of a `DataChannel` method that is used by child contexts to execute queries.
  `GraphDiff`
  `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.
  `QueryResponse`
  `performGenericQuery(Query query)`
  Executes a query returning a generic response.
  `ResultIterator`
  `performIteratedQuery(Query query)`
  Performs a single database select query returning result as a `ResultIterator`.
  `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.
  `List`
  `performQuery(Query query)`
  Performs a single selecting query.
  `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, recursively registering all transient persistent objects attached to this object via relationships.
  `void`
  `removeUserProperty(String key)`
  Removes a user-defined property.
  `void`
  `rollbackChanges()`
  Reverts any changes that have occurred to objects registered with DataContext; also performs cascading rollback of all parent DataContexts.
  `void`
  `rollbackChangesLocally()`
  If 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>`
  `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`
  `setChannel(DataChannel channel)`
  Sets a new DataChannel for this context.
  `void`
  `setDelegate(DataContextDelegate delegate)`
  Sets a DataContextDelegate for this context.
  `void`
  `setEntityResolver(EntityResolver entityResolver)`
  `void`
  `setQueryCache(QueryCache queryCache)`
  Sets a QueryCache to be used for storing cached query results.
  `void`
  `setTransactionFactory(TransactionFactory transactionFactory)`
  Deprecated.
  since 4.0 avoid using this directly.
  `void`
  `setUserProperty(String key, Object value)`
  Sets a user-defined property.
  `void`
  `setUsingSharedSnapshotCache(boolean flag)`
  `void`
  `setValidatingObjectsOnCommit(boolean flag)`
  Sets the property defining whether this ObjectContext should perform object validation before commit is executed.
  `Collection<?>`
  `uncommittedObjects()`
  Returns a collection of all uncommitted registered objects.
  `void`
  `unregisterObjects(Collection<?> objects)`
  Unregisters a Collection of Persistent objects from the DataContext and the underlying ObjectStore.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### BaseContext

    protected BaseContext()
    Deprecated, for removal: This API element is subject to removal in a future version.