|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eocontrol.EOObjectStore com.webobjects.eocontrol.EOCooperatingObjectStore com.webobjects.eoaccess.EODatabaseContext
public class EODatabaseContext
EODatabaseContext is the basic EOObjectStore for the EOAccess Framework. It acts as one of possibly several EOCooperatingObjectStores for an EOObjectStoreCoordinator. It acts as a store for any entities in the model list of its EODatabase. When saving editing context changes, the EODatabaseContext searches the object graph using the editing context's list of inserted, deleted, and updated objects and determines exactly which changes need to be made in the database. It then creates an array of adaptorOperations which it hands to an adaptor channel for execution.
The EODatabaseContext knows how to interact with other EOCooperatingObjectStores to save changes made to an object graph in more than one database server.
When the EODatabaseContext is asked to fetch or write information to the database, it tries to use one of its EODatabaseChannels. If all of its channels are busy, it broadcasts a DatabaseChannelNeededNotification
in the hopes that some observer can provide a new channel for the
context or that an existing channel can be freed up.
An EODatabaseContext represents a single transaction scope on the database server, and determines the updating and locking stragegy used by the database layer. It is managed by an EODatabase object, which represents the main connection to the server. If the server supports multiple concurrent transaction sessions, the EODatabase may have several EODatabaseContexts. If the adaptor allows multiple channels per context, then an EODatabaseContext may in turn have several EODatabaseChannels, which handle actual access to the data on the server. Not all adaptors support multiple contexts per database object. See EODatabase and EODatabaseChannel documentation for more information.
As a subclass of EOCooperatingObjectStore, EODatabaseContext acts as one of possibly several EOCooperatingObjectStores for an EOObjectStoreCoordinator, which mediates between EOEditingContexts and EOCooperatingObjectStores. (EOObjectStore, EOCooperatingObjectStore, and EOObjectStoreCoordinator are provided by the control layer.)
An EODatabaseContext creates an EOAdaptorContext when initialized, and uses this object to communicate with the database server.
Though you can create an EODatabaseContext explicitly by using the static method registeredDatabaseContextForModel
, you should rarely need to do so. If you are using the "higher-level" objects EOEditingContexts (EOControl) and EODatabaseDataSources, the database contexts
those objects need are created automatically, on demand. When you create database data source (typically for use with the interface layer's EODisplayGroup or WebObject's WODisplayGroup), it registers a database context that is capable of fetching objects for the data source's entities. If objects
fetched into an editing context (described more in the following section) have references to objects from EOModels that are based on another database, an EODatabaseContext is created and registered for each of the additional databases.
EODatabaseContexts are created on demand when an EOObjectStoreCoordinator (EOControl) posts a CooperatingObjectStoreNeeded
notification. The EODatabaseContext class registers for the notification, and it provides the coordinator with a new EODatabaseContext instance that can handle
the request.
For the most part, you don't need to programmatically interact with an EODatabaseContext. Some cases in which this might be necessary are:
Conceptually, an EODatabaseContext fetches and saves objects on behalf of an EOEditingContext (EOControl). However, the two objects don't interact with each other directly. An EOObjectStoreCoordinator (EOControl) acts as a mediator between them. When an editing context fetches objects, the request is passed through the coordinator, which forwards it to the appropriate database context based on the fetch specification or global ID. EODatabaseContext knows how to interact with other EOCooperatingObjectStores to save changes made to an object graph in more than one database server.
When the database context receives a request to fetch or write information to the database, it tries to use one of its EODatabaseChannels. If all of its channels are busy, it broadcasts an DatabaseChannelNeededNotification
in the hopes that an observer can provide a new channel or
that an existing channel can be freed up. This observer could be a manager object that decides how many database cursors can be opened by a particular client.
EODatabaseContext defines a hint for use with an EOFetchSpecification (EOControl) in the method objectsWithFetchSpecification
. Named by the key CustomQueryExpressionHintKey
, the hint's value is an SQL string for performing the fetch. The expression must query the
same attributes in the same order that Enterprise Objects Framework would if it were generating the SELECT expression dynamically. If this key is supplied, other characteristics of the EOFetchSpecification such as isDeep
, qualifier
, and sortOrderings
are ignored. In that sense, this key is more of a directive than a hint.
When an EODatabaseContext fetches an object, it examines the relationships defined in the model and creates objects representing the destinations of the fetched object's relationships. For example, if you fetch an employee object, you can ask for its manager and immediately receive the object. You don't have to obtain the manager's employee ID from the employee object and then use it fetch the manager.
However, EODatabaseContext doesn't immediately fetch data for the destination objects of relationships since fetching is fairly expensive. To avoid this waste of time and resources, the destination objects aren't initially filled with fetched data. Instead, they exist without any of their values until those values are actually needed. When the "empty" destination object (called a fault) is accessed for the first time, it "fires the fault", that is, it triggers its EODatabaseContext to fetch its data.
There are two types of faults: single object faults for to-one relationships and array faults for to-many relationships. When an array fault is accessed, it fetches all of the destination objects and replaces itself with an array of those objects. You can fine-tune faulting behavior for additional performance gains by using two different mechanisms: batch faulting, and prefetching relationships.
Triggering one fault has no effect on other faults. The destination object or objects for that one fault are fetched from the database, incurring the overhead of a roundtrip to the database server. You can take advantage of this expensive round trip to the database server by batching faults
together ith the method batchFetchRelationship
. For example, given an array of Employee objects, this method can fetch all of their departments with a single round trip to the server, rather than asking the server for each of the employees' departments individually. The delegate
methods databaseContextShouldFetchArrayFault
and databaseContextShouldFetchObjectFault
can be used to to fine-tune batch faulting behavior.
Batch faulting can also be set in an EOModel. In that approach, you specify the number of faults that should be triggered along with the first fault. In this case, you don't actually control which faults are batch fetched the ay you would by using batchFetchRelationship
.
An EODatabaseContext shares its delegate with its EODatabaseChannels. These delegate methods are actually sent from EODatabaseChannel, but they're defined in EODatabaseContext for ease of access:
You can use the EODatabaseContext delegate methods to intervene when objects are created and when they're fetched from the database. This gives you more fine-grained control over such issues as how an object's primary key is generated (databaseContextNewPrimaryKey
), how and if
objects are locked (databaseContextShouldLockObjectWithGlobalID
), the fetch specification that is used to fetch objects (databaseContextShouldSelectObjects
), how batch faulting is performed (databaseContextShouldFetchArrayFault
and
databaseContextShouldFetchObjectFault
), and so on.
An EODatabase records snapshots for its EODatabaseContexts. These snapshots form the application's view of the current state of the database server. This global view is overridden locally by database contexts, which form their own snapshots as they make changes during a transaction. When a database context commits its top-level transaction, it reconciles all changed snapshots with the global view of the database object, so that other database contexts (except those with open transactions) immediately use the new snapshots as well.
EODatabaseContext supports three updating strategies defined in the EODatabaseContext class as integer values:
Constant | Description |
UpdateWithOptimisticLocking |
The default update strategy. Under optimistic locking, objects aren't locked immediately on being fetched from the server. Instead, whenever you attempt to save updates to an object in the database, the object's snapshot is used to ensure that the values in the corresponding database row haven't changed since the object was fetched. As long as the snapshot matches the values in the database, the update is allowed to proceed. |
UpdateWithPessimisticLocking |
Causes objects to be locked in the database when they are selected, ensuring that no one else can modify the objects until the transaction ends. However, this doesn't necessarily mean that either the select or the update operation will succeed. Other settings at the adaptor or physical
database level can cause an update to fail. When pessimistic locking is enabled, a transaction is automatically started upon the first access to the database. By default, all selects against the database are performed with "select FOR UPDATE". The transaction is ended either when
saveChangesInEditingContext is invoked and the transaction is committed or when revertAllObjects is invoked and the transaction is rolled back. By default, when the transaction is closed, all snapshots are invalidated and all objects based on those snapshots are
invalidated (refaulted). |
UpdateWithNoLocking |
Objects are never locked. No comparisons are made between the snapshot and the row to ensure that the values in the corresponding database row haven't changed since the object was fetched. |
EODatabaseContext also supports "on-demand" locking, in which specific optimistic locks can be promoted to database locks during the course of program execution. You can either use lockObjectWithGlobalID
to lock a database row for a particular object, or
objectsWithFetchSpecification
to fetch objects with a fetch specification that includes locking.
EODatabaseContext.registeredDatabaseContextForModel(EOModel aModel, EOEditingContext anEditingContext)
,
EODatabaseContext.lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EODatabaseContext.objectsWithFetchSpecification( EOFetchSpecification fetchSpecification, EOEditingContext anEditingContext)
,
EODatabaseContext.Delegate.databaseContextDidFetchObjects( EODatabaseContext dbCtxt, NSArray array , EOFetchSpecification fetchSpec, EOEditingContext ec)
,
EODatabaseContext.Delegate.databaseContextShouldSelectObjects( EODatabaseContext dbCtxt , EOFetchSpecification fetchSpec, EODatabaseChannel dbChannel)
,
EODatabaseContext.Delegate.databaseContextShouldUpdateCurrentSnapshot( EODatabaseContext dbCtxt , NSDictionary dic, NSDictionary dic2, EOGlobalID gid , EODatabaseChannel dbChannel)
,
EODatabaseContext.Delegate.databaseContextShouldUsePessimisticLock( EODatabaseContext dbCtxt , EOFetchSpecification fetchSpec, EODatabaseChannel dbChannel)
,
EODatabaseContext.Delegate.databaseContextNewPrimaryKey( EODatabaseContext dbCtxt , Object object, EOEntity entity)
,
EODatabaseContext.Delegate.databaseContextShouldLockObjectWithGlobalID( EODatabaseContext dbCtxt , EOGlobalID gid, NSDictionary dic)
,
EODatabaseContext.Delegate.databaseContextShouldFetchArrayFault( EODatabaseContext dbCtxt , Object object)
,
EODatabaseContext.Delegate.databaseContextShouldFetchObjectFault( EODatabaseContext dbCtxt , Object object)
,
EODatabaseContext.batchFetchRelationship( EORelationship relationship, NSArray objects, EOEditingContext anEditingContext)
,
EODatabaseContext.Delegate
Nested Class Summary | |
---|---|
static class |
EODatabaseContext.DatabaseContextEvent
DatabaseContextEvent is a subclass of EOEvent, the parent class for objects that gather information, such as duration or order of execution, about various operations in WebObjects. |
static interface |
EODatabaseContext.Delegate
This interface defines a delegate to EODatabaseContext to to handle specific requests that are ordinarily handled by EODatabaseContext. |
Field Summary | |
---|---|
static String |
CustomQueryExpressionHintKey
|
static String |
DatabaseChannelNeededNotification
This nofification is broadcast whenever an EODatabaseContext is asked to perform an object store operation, and it does not have an available databaseChannel. |
static String |
DatabaseContextKey
A key in an GenericAdaptorException's userInfo dictionary. |
static String |
DatabaseOperationsKey
A key in an GenericAdaptorException's userInfo dictionary. |
static String |
FailedDatabaseOperationKey
A key in an GenericAdaptorException's userInfo dictionary. |
static String |
StoredProcedureNameHintKey
|
static int |
UpdateWithNoLocking
Integer constant that identifies the locking strategy as no locking. |
static int |
UpdateWithOptimisticLocking
Integer constant that identifies the locking strategy as optimistic. |
static int |
UpdateWithPessimisticLocking
Integer constant that identifies the locking strategy as pessimistic. |
Fields inherited from class com.webobjects.eocontrol.EOObjectStore |
---|
DeletedKey, InsertedKey, InvalidatedAllObjectsInStoreNotification, InvalidatedKey, ObjectsChangedInStoreNotification, UpdatedKey |
Fields inherited from interface com.webobjects.foundation.NSLocking |
---|
OneCentury, OneDay, OneHour, OneMinute, OneSecond, OneWeek, OneYear |
Constructor Summary | |
---|---|
EODatabaseContext(EODatabase database)
Creates and returns a new EODatabaseContext with database assigned as the EODatabase object that the new context works. |
Method Summary | |
---|---|
EOAdaptorContext |
adaptorContext()
Returns the EOAdaptorContext used by the EODatabaseContext for communication with the database server. |
NSArray |
arrayFaultWithSourceGlobalID(EOGlobalID globalID,
String name,
EOEditingContext context)
Creates and returns a to-many fault for the relationship name whose source entity must be the entity identified by globalID in the editing context context . |
EODatabaseChannel |
availableChannel()
Returns the first database channel that isn't busy from the the list of EODatabaseChannels registered with the receiver. |
void |
batchFetchRelationship(EORelationship relationship,
NSArray objects,
EOEditingContext editingContext)
Clears all the faults for relationship pointed by the source objects in objects and performs a single, efficient fetch or, at most, two fetches if the relationship is many-to-many. |
void |
cleanupSnapshots()
Force the weak references hold by this context to be freed. |
void |
commitChanges()
Instructs the adaptor to commit the transaction. |
static Class |
contextClassToRegister()
Returns the class that is created when a CooperatingObjectStoreNeeded notification is posted by an EOObjectStoreCoordinator. |
EODatabase |
database()
Returns the receiver's EODatabase. |
static Object |
defaultDelegate()
Returns the default delegate that will be used when initializing new EODatabaseContext instances. |
Object |
delegate()
Returns the receiver's delegate. |
void |
dispose()
Conformance to NSDisposable. |
void |
editingContextDidForgetObjectWithGlobalID(EOEditingContext context,
EOGlobalID gid)
Invoked when the editing context context is no longer using the object corresponding to gid . |
EOEnterpriseObject |
faultForGlobalID(EOGlobalID globalID,
EOEditingContext context)
Creates a to-one fault for the object identified by globalID and registers it in the editing context context . |
EOEnterpriseObject |
faultForRawRow(NSDictionary row,
String entityName,
EOEditingContext editingContext)
Returns a fault for a raw row. |
static EODatabaseContext |
forceConnectionWithModel(EOModel model,
NSDictionary overrides,
EOEditingContext editingContext)
Forces the stack of objects in the EOAccess layer to be instantiated, if necessary, and then makes a connection to the database. |
void |
forgetAllLocks()
Clears all of the locks made for Enterprise Objects by the receiver. |
void |
forgetLocksForObjectsWithGlobalIDs(NSArray gids)
Clears the locks made for the Enterprise Objects identified by each of the EOGlobalIDs in gids . |
void |
forgetSnapshotForGlobalID(EOGlobalID gid)
Deletes the snapshot recorded for the Enterprise Object identified by gid . |
void |
forgetSnapshotsForGlobalIDs(NSArray gids)
Deletes the snapshots recorded for the Enterprise Objects identified by gids , both in the receiver and in the EODatabase. |
void |
handleDroppedConnection()
Cleans up after a database connection is dropped by unregistering the receiver's adaptor context and database channels, and then creating a new adaptor context. |
boolean |
handlesFetchSpecification(EOFetchSpecification fetchSpecification)
Returns true if the entity identified by the entity name in fetchSpecification can be found in one of the models owned by the EODatabase of the receiver, false
|
boolean |
hasBusyChannels()
Returns true if the receiver's EOAdaptorContext has channels that have outstanding operations (that is, have a fetch in progress), false otherwise. |
void |
initializeObject(EOEnterpriseObject object,
EOGlobalID gid,
EOEditingContext context)
Initializes the enteprise object object in the editing context context based on the snapshot for gid . |
void |
invalidateAllObjects()
Discards all snapshots in the receiver's EODatabase, forgets all object locks, and posts an InvalidatedAllObjectsInStoreNotification , as well as an ObjectsChangedInStoreNotification with the globalIDs for the invalidated objects in the userInfo
dictionary. |
void |
invalidateObjectsWithGlobalIDs(NSArray gids)
Discards the snapshots for the objects identified by the EOGlobalIDs in gids and broadcasts an ObjectsChangedInStoreNotification , which causes any EOEditingContext containing objects fetched from the receiver to refault those objects. |
boolean |
isObjectLockedWithGlobalID(EOGlobalID gid)
Returns true if the Enterprise Object identified by gid is locked, false otherwise. |
boolean |
isObjectLockedWithGlobalID(EOGlobalID gid,
EOEditingContext ec)
Returns true if the row corresponding to the globalID gid has been locked in an open transaction held by this database context. |
static boolean |
isSharedObjectLoadingEnabled()
Returns true if the database contexts automatically load enterprise objects into the default shared editing context when they load a model which contains shared object fetch specifications, false if automatic loading is disabled. |
NSDictionary |
localSnapshotForGlobalID(EOGlobalID gid)
Returns the snapshot for the object identified by gid , if there is one, otherwise returns null . |
NSArray |
localSnapshotForSourceGlobalID(EOGlobalID gid,
String name)
Returns the to-many snapshot for the relationship named name belonging to the Enterprise Object identified by the globalID gid , or null if there is no to-many snapshot. |
void |
lock()
This method is used to protect access to the receiver from concurrent operations by multiple threads. |
void |
lockObjectWithGlobalID(EOGlobalID gid,
EOEditingContext ec)
Attempts to lock the database row corresponding to gid in the underlying database server on behalf of the editing context ec . |
NSArray |
missingObjectGlobalIDs()
Returns an array of the globalIDs of any missing Enterprise Objects, or an empty array if no missing objects are known to the receiver. |
NSArray |
objectsForSourceGlobalID(EOGlobalID gid,
String name,
EOEditingContext context)
Services a to-many fault. |
NSArray |
objectsWithFetchSpecification(EOFetchSpecification fetchSpec,
EOEditingContext context)
Fetches objects from an external store into context . |
boolean |
ownsGlobalID(EOGlobalID globalID)
Returns true if the receiver is responsible for fetching and saving the object identified by globalID , false otherwise. |
boolean |
ownsObject(EOEnterpriseObject object)
Returns true if the receiver is responsible for fetching and saving object , false otherwise. |
void |
performChanges()
Constructs EOAdaptorOperations for all the EODatabaseOperations produced during recordChangesInEditingContext and recordUpdateForObject . |
void |
prepareForSaveWithCoordinator(EOObjectStoreCoordinator coordinator,
EOEditingContext editingContext)
Prepares to save changes. |
void |
recordChangesInEditingContext()
Constructs a list of EODatabaseOperations for all changes to objects in the EOEditingContext that are owned by the receiver. |
void |
recordSnapshotForGlobalID(NSDictionary snapshot,
EOGlobalID gid)
Records snapshot under the globalID gid . |
void |
recordSnapshotForSourceGlobalID(NSArray gids,
EOGlobalID gid,
String name)
For the object identified by gid gids, which is the array of globalIDs identifying the
destination objects for the to-many relationship named name . |
void |
recordSnapshots(NSDictionary snapshots)
Records the snapshots in snapshots , which is a dictionary whose keys are globalIDs and whose values are the snapshots for the enterprise objects identified by those globalIDs. |
void |
recordToManySnapshots(NSDictionary snapshots)
Records a collection of to-many snapshots from a dictionary keyed by globalID. |
void |
recordUpdateForObject(EOEnterpriseObject object,
NSDictionary changes)
Applies changes supplied from another EOCooperatingObjectStore (through the EOObjectStoreCoordinator) to the database operation for object in the receiver. |
void |
refaultObject(EOEnterpriseObject object,
EOGlobalID globalID,
EOEditingContext context)
Refault the Enterprise Object identified by globalID in the editing context context . |
void |
registerChannel(EODatabaseChannel channel)
Registers the EODatabaseChannel channel with the receiver, adding it from the pool of available channels used to service fetch and fault requests. |
NSArray |
registeredChannels()
Returns an array containing all of the EODatabaseChannels that have been registered for use with the receiver. |
static EODatabaseContext |
registeredDatabaseContextForModel(EOModel model,
EOEditingContext editingContext)
Finds the EOObjectStoreCoordinator for editingContext and checks whether it already contains an EODatabaseContext cooperating store for model . |
static EODatabaseContext |
registeredDatabaseContextForModel(EOModel model,
EOObjectStoreCoordinator coordinator)
Returns the cooperating object store that is registered with the EOObjectStoreCoordinator coordinator for the EOModel model . |
void |
registerLockedObjectWithGlobalID(EOGlobalID gid)
Registers as a locked object the Enterprise Object identified by gid . |
void |
rollbackChanges()
Instructs the adaptor to roll back the transaction. |
void |
saveChangesInEditingContext(EOEditingContext context)
Sent by an EOEditingContext context to its EOObjectStore to commit changes. |
static void |
setContextClassToRegister(Class contextClass)
Sets the class that is created and registered when a CooperatingObjectStoreNeeded notification is posted by an EOObjectStoreCoordinator to contextclass . |
void |
setCoordinator(EOObjectStoreCoordinator coord)
|
static void |
setDefaultDelegate(Object defaultDelegate)
Sets the default delegate for new instances of EODatabaseContext to defaultDelegate . |
void |
setDelegate(Object delegate)
Sets delegate as the delegate for the receiver and all the receiver's EODatabaseChannels. |
static void |
setSharedObjectLoadingEnabled(boolean bool)
Based on the value of the Boolean parameter bool , enables or disables automatic loading of Enterprise Objects into the default shared editing context when a database context loads a model which contains shared object fetch specifications. |
void |
setUpdateStrategy(int strategy)
Sets the update strategy used by the receiver to strategy , which must be one of the following constants:UpdateWithOptimisticLocking
UpdateWithPessimisticLocking
UpdateWithNoLocking
Throws an exception if the receiver has any transactions in progress, or if you try to set strategy to UpdateWithPessimisticLocking and the receiver's EODatabase already has snapshots. |
NSDictionary |
snapshotForGlobalID(EOGlobalID gid)
Returns the snapshot associated with gid or null if there isn't one. |
NSDictionary |
snapshotForGlobalID(EOGlobalID gid,
long timestamp)
Returns the snapshot for the Enterprise Object identified by the globalID gid , provided the snapshot's timestamp is greater than or equal to timestamp . |
NSArray |
snapshotForSourceGlobalID(EOGlobalID gid,
String name)
Returns the to-many snapshot for the relationship named name belonging to the Enterprise Object identified by the globalID gid , or null if there is no to-many snapshot. |
NSArray |
snapshotForSourceGlobalID(EOGlobalID gid,
String name,
long timestamp)
Returns the to-many snapshot for the globalID gid and relationship name , provided that the timestamp of the snapshot is greater than or equal to timestamp . |
void |
unlock()
This method is used to protect access to the receiver from concurrent operations by multiple threads. |
void |
unregisterChannel(EODatabaseChannel channel)
Unregisters the EODatabaseChannel channel with the receiver, removing it from the pool of available channels used to service fetch and fault requests. |
int |
updateStrategy()
Returns the update strategy used by the receiver, one of the following constants: UpdateWithOptimisticLocking
UpdateWithPessimisticLocking
UpdateWithNoLocking
The default strategy is UpdateWithOptimisticLocking . |
NSDictionary |
valuesForKeys(NSArray keys,
EOEnterpriseObject object)
Returns values for the specified keys from the snapshot of object . |
Methods inherited from class com.webobjects.eocontrol.EOCooperatingObjectStore |
---|
coordinator |
Methods inherited from class com.webobjects.eocontrol.EOObjectStore |
---|
invokeRemoteMethod, setUserInfo, setUserInfoForKey, userInfo, userInfoForKey |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int UpdateWithOptimisticLocking
public static final int UpdateWithPessimisticLocking
public static final int UpdateWithNoLocking
public static final String DatabaseChannelNeededNotification
public static final String CustomQueryExpressionHintKey
public static final String StoredProcedureNameHintKey
public static final String DatabaseContextKey
public static final String DatabaseOperationsKey
public static final String FailedDatabaseOperationKey
Constructor Detail |
---|
public EODatabaseContext(EODatabase database)
database
assigned as the EODatabase object that the new context works. Throws an exception if unable to obtain a new EOAdaptorContext from the underlying adaptor.
database
- The EODatabase object that the new EODatabaseContext uses.
IllegalStateException
- if the underlying adaptor context can't create a corresponding adaptor channel.EODatabaseContext.database()
,
EODatabaseContext
Method Detail |
---|
public static void setDefaultDelegate(Object defaultDelegate)
defaultDelegate
.
defaultDelegate
- The object to be assigned as delegate to new instances of EODatabaseContext.public static Object defaultDelegate()
null
unless the default delegate has been set with setDefaultDelegate
.
null
.EODatabaseContext.setDefaultDelegate(Object defaultDelegate)
public static void setSharedObjectLoadingEnabled(boolean bool)
bool
, enables or disables automatic loading of Enterprise Objects into the default shared editing context when a database context loads a model which contains shared object fetch specifications. Automatic loading is enabled by
default.
bool
- Boolean flag that enables/disables automatic loading of objects into the default shared editing context.EOEntity.sharedObjectFetchSpecificationNames()
public static boolean isSharedObjectLoadingEnabled()
true
if the database contexts automatically load enterprise objects into the default shared editing context when they load a model which contains shared object fetch specifications, false
if automatic loading is disabled.
true
if database contexts automatically load enterprise objects into the default shared editing context.EOEntity.sharedObjectFetchSpecificationNames()
public void dispose()
dispose
in interface NSDisposable
dispose
in class EOObjectStore
public static Class contextClassToRegister()
CooperatingObjectStoreNeeded
notification is posted by an EOObjectStoreCoordinator. The default is EODatabaseContext. Use setContextClassToRegister
to specify a subclass of EODatabaseContext instead.
When an EOObjectStoreCoordinator sends a CooperatingObjectStoreNeeded
notification for an entity in the default model group, an instance of the context class is created, the EOModel for the entity is registered, and the context class is registered with the requesting
EOObjectStoreCoordinator.
CooperatingObjectStoreNeeded
notification.EODatabaseContext.setContextClassToRegister(Class contextClass)
public static void setContextClassToRegister(Class contextClass)
CooperatingObjectStoreNeeded
notification is posted by an EOObjectStoreCoordinator to contextclass
.
contextClass
- The class to instantiate in response to a CooperatingObjectStoreNeeded
notification.EODatabaseContext.contextClassToRegister()
public static EODatabaseContext registeredDatabaseContextForModel(EOModel model, EOObjectStoreCoordinator coordinator)
coordinator
for the EOModel model
. If no cooperating object store is registered for model
, this method instantiates a new EODatabaseContext, adds it to the
coordinator, and returns it.
model
- An EOModel.coordinator
- An EOObjectStoreCoordinator.
coordinator
for model
.public static EODatabaseContext registeredDatabaseContextForModel(EOModel model, EOEditingContext editingContext)
editingContext
and checks whether it already contains an EODatabaseContext cooperating store for model
. If it does, it returns that EODatabaseContext. Otherwise it instantiates a new EODatabaseContext, adds it to the
coordinator, and returns it.
model
- The current EOModel.editingContext
- The editing context.
model
.public static EODatabaseContext forceConnectionWithModel(EOModel model, NSDictionary overrides, EOEditingContext editingContext)
model
, it is first closed and then reconnected with a new connection dictionary made up of the original
connection dictionary overlaid with the alternate values for keys specified in overrides
. All compatible models in the model group also are associated with the new connection so that they share the same adaptor. Returns the EODatabaseContext associated with the model for the
given editingContext
.
model
- The EOModel.overrides
- Alternate values for specified keys in the connection dictionary.editingContext
- The EOEditingContext.
public void setCoordinator(EOObjectStoreCoordinator coord)
setCoordinator
in class EOCooperatingObjectStore
coord
- the coordinator this cooperating store is has been registered withEOObjectStoreCoordinator.addCooperatingObjectStore(com.webobjects.eocontrol.EOCooperatingObjectStore)
,
EOObjectStoreCoordinator.removeCooperatingObjectStore(com.webobjects.eocontrol.EOCooperatingObjectStore)
public NSArray registeredChannels()
EODatabaseContext.availableChannel()
,
EODatabaseContext.registeredChannels()
,
EODatabaseContext.unregisterChannel(EODatabaseChannel channel)
public void registerChannel(EODatabaseChannel channel)
channel
with the receiver, adding it from the pool of available channels used to service fetch and fault requests. Throws an exception if the receiver is not the parent object for channel
or if channel
is already
registered with the receiver.
Use this method if you need to perform more than one fetch simultaneously.
channel
- The EODatabaseChannel to be registered with the receiver.
IllegalStateException
- if the receiver is not the parent for channel
, or if channel
is already registered with the receiver.EODatabaseContext.availableChannel()
,
EODatabaseContext.registeredChannels()
,
EODatabaseContext.unregisterChannel(EODatabaseChannel channel)
public void unregisterChannel(EODatabaseChannel channel)
channel
with the receiver, removing it from the pool of available channels used to service fetch and fault requests. Throws an exception if channel
is not registered with the receiver.
channel
- The EODatabaseChannel to unregister with the receiver.
IllegalStateException
- if channel
is not registered with the receiver.EODatabaseContext.registerChannel(EODatabaseChannel channel)
,
EODatabaseContext.registeredChannels()
,
EODatabaseContext.availableChannel()
public EODatabaseChannel availableChannel()
DatabaseChannelNeededNotification
, then checks the list of available channels again to see if one has been
added. If there are still no available channels, the receiver creates and opens a new EODatabaseChannel if possible, otherwise the method returns null
.
null
.EODatabaseContext.DatabaseChannelNeededNotification
,
EODatabaseContext.registerChannel(EODatabaseChannel channel)
,
EODatabaseContext.registeredChannels()
,
EODatabaseContext.unregisterChannel(EODatabaseChannel channel)
public boolean hasBusyChannels()
true
if the receiver's EOAdaptorContext has channels that have outstanding operations (that is, have a fetch in progress), false
otherwise.
true
if the receiver's EOAdaptorContext has channels with outstanding operations.public EODatabase database()
EODatabaseContext.EODatabaseContext(EODatabase aDatabase)
public EOAdaptorContext adaptorContext()
public int updateStrategy()
UpdateWithOptimisticLocking
UpdateWithPessimisticLocking
UpdateWithNoLocking
UpdateWithOptimisticLocking
.
EODatabaseContext.setUpdateStrategy(int strategy)
public void setUpdateStrategy(int strategy)
strategy
, which must be one of the following constants:UpdateWithOptimisticLocking
UpdateWithPessimisticLocking
UpdateWithNoLocking
strategy
to UpdateWithPessimisticLocking
and the receiver's EODatabase already has snapshots.
strategy
- The update strategy used by the receiver.
IllegalArgumentException
- if strategy
is UpdateWithPessimisticLocking
and the receiver's EODatabase contains snapshots.EODatabaseContext.updateStrategy()
public void recordSnapshotForGlobalID(NSDictionary snapshot, EOGlobalID gid)
snapshot
under the globalID gid
. Throws an exception in the following conditions:gid
is null
.snapshot
is null
This method only records snapshots locally (in the transaction scope). If you want to record snapshots globally, use the corresponding EODatabase method.
snapshot
- The dictionary representation of an Enterprise Object with the
last known values from the database.gid
- The EOGlobalID identifying snapshot
's Enterprise Object.
IllegalArgumentException
- if either parameter is null
.
IllegalStateException
- if there is no transaction in progress.EODatabase
,
EODatabaseContext.recordSnapshotForGlobalID(NSDictionary aSnapshot,EOGlobalID
aGlobalID)
,
EODatabaseContext.localSnapshotForGlobalID(EOGlobalID globalID)
,
EODatabaseContext.recordSnapshots(NSDictionary snapshots)
,
EODatabaseContext.snapshotForGlobalID(EOGlobalID globalID, long timestamp)
,
EODatabaseContext.forgetSnapshotForGlobalID(EOGlobalID gid)
public void recordSnapshotForSourceGlobalID(NSArray gids, EOGlobalID gid, String name)
gid
gids, which is the array of globalIDs identifying the
destination objects for the to-many relationship named name
.
Throws an exception in the following conditions:gid
is null
.gids
is null
This method only records snapshots locally (in the transaction scope). If you want to record snapshots globally, use the corresponding EODatabase method.
gids
- Array of globalIDs identifying the objects at the destination of the relationship.gid
- Identifies the Enterprise Object whose to-many relationship is
being snapshotted.name
- The name of the to-many relationship being snapshotted.
IllegalArgumentException
- if gid
or gids
is
null
.
IllegalStateException
- if there is no transaction in progress.EODatabase
,
EODatabaseContext.snapshotForSourceGlobalID(EOGlobalID gid, String name
, long timestamp)
,
EODatabaseContext.localSnapshotForSourceGlobalID(EOGlobalID globalID, String name)
,
EODatabaseContext.recordToManySnapshots(NSDictionary snapshots)
public void recordSnapshots(NSDictionary snapshots)
snapshots
, which is a dictionary whose keys are globalIDs and whose values are the snapshots for the enterprise objects identified by those globalIDs. Throws an exception if invoked when no transaction is in progress.
This method only records snapshots locally (in the transaction scope). If you want to record snapshots globally, use the corresponding EODatabase method.
snapshots
- A dictionary of snapshots to record, keyed by globalID.
IllegalStateException
- if no transaction is in progress.EODatabase
,
EODatabaseContext.recordSnapshotForGlobalID(NSDictionary aSnapshot, EOGlobalID aGlobalID)
,
EODatabaseContext.localSnapshotForGlobalID(EOGlobalID globalID)
,
EODatabaseContext.forgetSnapshotForGlobalID(EOGlobalID gid)
,
EODatabaseContext.snapshotForSourceGlobalID(EOGlobalID gid, String name, long timestamp)
public void recordToManySnapshots(NSDictionary snapshots)
snapshots
parameter should be a dictionary of NSDictionaries. The top-level dictionary has as its key the globalID of the Enterprise Object for which to-many relationship snapshots are being
recorded. That key's value is a dictionary whose keys are the names of the Enterprise Object's to-many relationships, and whose values are arrays of globalIDs that identify the objects at the destination of each relationship. Throws an exception if invoked when no transaction is in progress
This method only records snapshots locally (in the transaction scope). If you want to record snapshots globally, use the corresponding EODatabase method.
snapshots
- A dictionary of dictionaries, keyed by globalIDs, representing the snapshots for the to-many relationships of the Enterprise Object identifed by the top-level key.
IllegalStateException
- if no transaction is in progress.EODatabase
,
EODatabaseContext.recordSnapshotForSourceGlobalID(NSArray globalIDs, EOGlobalID globalID, String name)
,
EODatabaseContext.snapshotForSourceGlobalID(EOGlobalID globalId, String name, long timestamp)
,
EODatabaseContext.localSnapshotForSourceGlobalID(EOGlobalID gid, String name)
public void forgetSnapshotForGlobalID(EOGlobalID gid)
gid
. Throws an exception if invoked when no transaction is in progress, or if gid
is null
.
This method only applies to snapshots locally (in the transaction scope). If you want to forget snapshots globally, use the corresponding EODatabase method.
gid
- The globalID for an Enterprise Object.
IllegalArgumentException
- if gid
is null
.
IllegalStateException
- if there is no transaction in progress.EODatabase
,
EODatabaseContext.recordSnapshotForGlobalID(NSDictionary aSnapshot,EOGlobalID aGlobalID)
,
EODatabaseContext.localSnapshotForGlobalID(EOGlobalID globalID)
,
EODatabaseContext.recordSnapshots(NSDictionary snapshots)
,
EODatabaseContext.snapshotForGlobalID(EOGlobalID globalID, long timestamp)
,
EODatabaseContext.forgetSnapshotsForGlobalIDs(NSArray globalIDs)
public NSDictionary snapshotForGlobalID(EOGlobalID gid)
gid
or null
if there isn't one. Searches first locally (in the transaction scope) and then in the EODatabase.
gid
- The globalID of an Enterprise Object whose snapshot to return.
gid
, or null
.EODatabaseContext.recordSnapshotForGlobalID(NSDictionary aSnapshot, EOGlobalID aGlobalID)
,
EODatabaseContext.forgetSnapshotForGlobalID(EOGlobalID gid)
public NSDictionary snapshotForGlobalID(EOGlobalID gid, long timestamp)
gid
, provided the snapshot's timestamp is greater than or equal to timestamp
. Returns null
if there isn't a snapshot for gid
or if the snapshot's timestamp
is earlier (less) than the reference timestamp
. Searches first locally (in the transaction scope) and then in the EODatabase.
gid
- The globalID of an Enterprise Object whose snapshot to return.timestamp
- A reference timestamp to compare with the snapshot's timestamp.
gid
, or null
.EODatabaseContext.recordSnapshotForGlobalID(NSDictionary aSnapshot, EOGlobalID aGlobalID)
,
EODatabaseContext.forgetSnapshotForGlobalID(EOGlobalID gid)
public NSArray snapshotForSourceGlobalID(EOGlobalID gid, String name)
name
belonging to the Enterprise Object identified by the globalID gid
, or null
if there is no to-many snapshot. Searches first locally (in the transaction scope) and then in the EODatabase.
A to-many snapshot is an array of globalIDs which identify the objects at the destination of a to-many relationship.
gid
- The globalID for the Enterprise Object that owns the relationship name
.name
- The name of the to-many relationship whose snapshot to return.
gid
and name
, or null
.public NSArray snapshotForSourceGlobalID(EOGlobalID gid, String name, long timestamp)
gid
and relationship name
, provided that the timestamp of the snapshot is greater than or equal to timestamp
. Returns null
if there isn't a to-many snapshot for gid
and
name
, or if the snapshot's timestamp is earlier (less) than the reference timestamp
. Searches first locally (in the transaction scope) and then in the EODatabase.
gid
- The globalID for the Enterprise Object that owns the relationship name
.name
- The name of the to-many relationship whose snapshot to return.timestamp
- The reference timestamp to compare with the snapshot's timestamp.
gid
and name
, or null
.public NSArray missingObjectGlobalIDs()
If an application tries to save a missing object, an exception is thrown. To be notified when a missing object is discovered, implement the delegate method databaseContextFailedToFetchObject
.
public Object delegate()
EODatabaseContext.setDelegate(Object delegate)
public void setDelegate(Object delegate)
delegate
as the delegate for the receiver and all the receiver's EODatabaseChannels.
delegate
- The object to set as the delegate for the receiver and its database channels.EODatabaseContext.delegate()
public void lock()
lock
in interface NSLocking
lock
in class EOCooperatingObjectStore
EODatabaseContext.unlock()
,
EOObjectStoreCoordinator
public void unlock()
unlock
in interface NSLocking
unlock
in class EOCooperatingObjectStore
EODatabaseContext.lock()
,
EOObjectStoreCoordinator
public void handleDroppedConnection()
Do not invoke this method yourself. It is invoked automatically by the Framework.
IllegalStateException
- if unable to obtain a new EOAdaptorContext from the underlying adaptor.public NSDictionary localSnapshotForGlobalID(EOGlobalID gid)
gid
, if there is one, otherwise returns null
. Only searches locally (in the transaction scope), not in the EODatabase.
gid
- The globalID identifying the Enterprise Object whose local snapshot to return.
gid
, or null
.EODatabaseContext.recordSnapshotForGlobalID(NSDictionary aSnapshot,EOGlobalID aGlobalID)
,
EODatabaseContext.recordSnapshots(NSDictionary snapshots)
,
EODatabaseContext.snapshotForGlobalID(EOGlobalID globalID, long timestamp)
,
EODatabaseContext.forgetSnapshotsForGlobalIDs(NSArray globalIDs)
public NSArray localSnapshotForSourceGlobalID(EOGlobalID gid, String name)
name
belonging to the Enterprise Object identified by the globalID gid
, or null
if there is no to-many snapshot. A to-many snapshot is an array of globalIDs which identify the objects at the
destination of a to-many relationship. Only searches locally (in the transaction scope), not in the EODatabase.
gid
- The globalID for the Enterprise Object that owns the relationship name
.name
- The name of the to-many relationship whose snapshot to return.
gid
and name
, or null
.EODatabaseContext.recordSnapshotForGlobalID(NSDictionary aSnapshot, EOGlobalID aGlobalID)
,
EODatabaseContext.snapshotForSourceGlobalID(EOGlobalID gid, String name, long timestamp)
public void registerLockedObjectWithGlobalID(EOGlobalID gid)
gid
. This method is used internally by the Framework to keep track of objects corresponding to rows that are locked in the database.
gid
- A globalID identifying an Enterprise Object that corresponds to a locked row in the database.EODatabaseContext.forgetAllLocks()
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EODatabaseContext.forgetLocksForObjectsWithGlobalIDs(NSArray gids)
,
EODatabaseContext.lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EOEditingContext.lockObject(EOEnterpriseObject object)
public boolean isObjectLockedWithGlobalID(EOGlobalID gid)
true
if the Enterprise Object identified by gid
is locked, false
otherwise.
gid
- A globalID identifying an Enterprise Object.
true
if the Enterprise Object identified by code>gid is locked.EODatabaseContext.forgetLocksForObjectsWithGlobalIDs(NSArray gids)
,
EODatabaseContext.forgetAllLocks()
,
EODatabaseContext.registerLockedObjectWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EODatabaseContext.lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EOEditingContext.lockObject(EOEnterpriseObject object)
public void forgetLocksForObjectsWithGlobalIDs(NSArray gids)
gids
. Does not unlock the corresponding rows in the database server.
gids
- An array of globalIDs identifying objects which correspond to locked rows in the database.EODatabaseContext.forgetAllLocks()
,
EODatabaseContext.registerLockedObjectWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EODatabaseContext.lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EOEditingContext.lockObject(EOEnterpriseObject object)
public void forgetAllLocks()
This method is invoked whenever a transaction is committed or rolled back.
EODatabaseContext.registerLockedObjectWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EODatabaseContext.forgetLocksForObjectsWithGlobalIDs(NSArray gids)
,
EODatabaseContext.lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EOEditingContext.lockObject(EOEnterpriseObject object)
public void forgetSnapshotsForGlobalIDs(NSArray gids)
gids
, both in the receiver and in the EODatabase.
gids
- An array of globalIDs for Enterprise Objects whose snapshots should be deleted.EODatabaseContext.recordSnapshotForGlobalID(NSDictionary aSnapshot,EOGlobalID aGlobalID)
,
EODatabaseContext.localSnapshotForGlobalID(EOGlobalID globalID)
,
EODatabaseContext.recordSnapshots(NSDictionary snapshots)
,
EODatabaseContext.snapshotForGlobalID(EOGlobalID globalID, long timestamp)
public EOEnterpriseObject faultForRawRow(NSDictionary row, String entityName, EOEditingContext editingContext)
row
is the raw data, in the form of an NSDictionary. entityName
is the name of the appropriate entity for the Enterprise Object you want to create as a fault. editingContext
is the EOEditingContext in which to create
the fault. Throws an exception if row
does not contain primary key information for entityName
.
faultForRawRow
in class EOObjectStore
row
- The raw data for the row, in the form of an NSDictionary.entityName
- The name of the appropriate entity for the Enterprise Object fault to be created.editingContext
- The EOEditingContext in which to create the fault.
IllegalArgumentException
- if row
does not contain primary key information.EOEditingContext.faultForRawRow(com.webobjects.foundation.NSDictionary, java.lang.String, com.webobjects.eocontrol.EOEditingContext)
,
EODatabaseContext.faultForRawRow(com.webobjects.foundation.NSDictionary, java.lang.String, com.webobjects.eocontrol.EOEditingContext)
public NSArray objectsWithFetchSpecification(EOFetchSpecification fetchSpec, EOEditingContext context)
context
. The receiver obtains an available EODatabaseChannel and performs a fetch with fetchSpec
. Returns an array containing the fetched objects. If one of the fetched objects is already present in memory, by default
this method doesn't overwrite its values with the new values from the database.
You can fine-tune the fetching behavior by adding hints to fetchSpec
's hints dictionary. The class description for EOFetchSpecification contains additional information on using hints. You can also use this method to implement on-demand locking by using a fetch
specification that includes locking.
Throws an exception if an error occurs; the error message indicates the nature of the problem.
objectsWithFetchSpecification
in class EOObjectStore
fetchSpec
- The criteria to select and order a group of database records.context
- The EOEditingContext into which objects are to be fetched.
(EOFetchSpecification fetchSpec, EOEditingContext context)
public boolean isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext ec)
true
if the row corresponding to the globalID gid
has been locked in an open transaction held by this database context.
isObjectLockedWithGlobalID
in class EOObjectStore
gid
- The globalID identifying an Enterprise Object.ec
- The EOEditingContext.
true
if the database row corresponding to gid
has been locked in an open transaction held by the receiver.EODatabaseContext.forgetLocksForObjectsWithGlobalIDs(NSArray gids)
,
EODatabaseContext.forgetAllLocks()
,
EODatabaseContext.registerLockedObjectWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EODatabaseContext.lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EOEditingContext.lockObject(EOEnterpriseObject object)
public void lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec)
gid
in the underlying database server on behalf of the editing context ec
. If a transaction is not already open at the time of the lock request, the transaction is begun and is held open until either
commitChanges
or invalidateAllObjects
is invoked. At that point all locks are released. Throws an exception if unable to obtain the lock.
lockObjectWithGlobalID
in class EOObjectStore
gid
- The globalID identifying an Enterprise Object whose corresponding database row should be locked.ec
- The EOEditingContext.
IllegalStateException
- if unable to obtain the lock.EODatabaseContext.forgetLocksForObjectsWithGlobalIDs(NSArray gids)
,
EODatabaseContext.forgetAllLocks()
,
EODatabaseContext.registerLockedObjectWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid)
,
EODatabaseContext.isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EODatabaseContext.lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec)
,
EOEditingContext.lockObject(EOEnterpriseObject object)
public void saveChangesInEditingContext(EOEditingContext context)
context
to its EOObjectStore to commit changes. Normally, the EODatabaseContext is not called directly by this method but is instead called by an EOObjectStoreCoordinator. Throws an exception if an error occurs; the error message indicates the nature
of the problem.
saveChangesInEditingContext
in class EOObjectStore
context
- The EOEditingContext in which the changes are to be saved.EOEditingContext.saveChangesInEditingContext(com.webobjects.eocontrol.EOEditingContext)
,
EODatabaseContext.saveChangesInEditingContext(com.webobjects.eocontrol.EOEditingContext)
,
EOAdaptor
public EOEnterpriseObject faultForGlobalID(EOGlobalID globalID, EOEditingContext context)
globalID
and registers it in the editing context context
. Throws an exception if globalID
is not an instance of EOKeyGlobalID.
faultForGlobalID
in class EOObjectStore
globalID
- Identifer for the Enterprise Object for which to create a fault.context
- The EOEditingContext.
globalID
.
IllegalArgumentException
- if globalID
is not an instance of EOKeyGlobalID.EODatabaseContext.arrayFaultWithSourceGlobalID(EOGlobalID globalID, String name, EOEditingContext context)
public void refaultObject(EOEnterpriseObject object, EOGlobalID globalID, EOEditingContext context)
globalID
in the editing context context
. Throws an exception if globalID
is not an instance of EOKeyGlobalID.
Newly-inserted objects should not be refaulted. Since they are not in the external store, they can not be refetched; attempting this will cause an exception to be thrown. Don't refault to-many relationship arrays, just recreate them.
This method should be used with caution since refaulting an object doesn't remove the object's snapshot from the undo stack, with the result that object snapshot may no longer refer to the proper object.
refaultObject
in class EOObjectStore
object
- The EOEnterpriseObject to turn back into a fault.globalID
- The unique identifier for object
.context
- The current EOEditingContext.
IllegalArgumentException
- if globalID
is not an instance of EOKeyGlobalID.EOEditingContext.refaultObject(com.webobjects.eocontrol.EOEnterpriseObject)
,
EODatabaseContext.refaultObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)
public NSArray arrayFaultWithSourceGlobalID(EOGlobalID globalID, String name, EOEditingContext context)
name
whose source entity must be the entity identified by globalID
in the editing context context
. Throws an exception if globalID
is not an instance of EOKeyGlobalID.
arrayFaultWithSourceGlobalID
in class EOObjectStore
globalID
- The unique identifier for the source entity for name
.name
- The EORelationship for which to create the fault.context
- The EOEditingContext.
globalID
and name
.
IllegalArgumentException
- if globalID
is not an instance of EOKeyGlobalID.EODatabaseContext.faultForGlobalID(EOGlobalID globalID, EOEditingContext anEditingContext)
public void initializeObject(EOEnterpriseObject object, EOGlobalID gid, EOEditingContext context)
object
in the editing context context
based on the snapshot for gid
. Throws an exception if gid
does not identify a valid object in the specified editing context.
Attributes in the snapshot that are marked as class properties in the EOEntity are assigned to object
. For relationship class properties, faults are constructed and assigned to the object.
initializeObject
in class EOObjectStore
object
- The Enterprise Object to initialize.gid
- The globalID for the snapshot from which to initialize object
.context
- The EOEditingContext.
IllegalStateException
- if gid
does not identify a valid object in context
.EOEnterpriseObject.awakeFromInsertion(com.webobjects.eocontrol.EOEditingContext)
,
EOEnterpriseObject.awakeFromFetch(com.webobjects.eocontrol.EOEditingContext)
,
EOEditingContext.initializeObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)
public void editingContextDidForgetObjectWithGlobalID(EOEditingContext context, EOGlobalID gid)
context
is no longer using the object corresponding to gid
. The receiver destroys related data, such as snapshots, for gid
if no other objects are using them.
Do not invoke this method yourself; it is invoked automatically by the Framework.
editingContextDidForgetObjectWithGlobalID
in class EOObjectStore
context
- The EOEditingContext.gid
- The globalID identifying an object no longer in use by context
.EODatabase.decrementSnapshotCountForGlobalID(EOGlobalID globalId)
,
EODatabase.incrementSnapshotCountForGlobalID(EOGlobalID globalID)
public void invalidateObjectsWithGlobalIDs(NSArray gids)
gids
and broadcasts an ObjectsChangedInStoreNotification
, which causes any EOEditingContext containing objects fetched from the receiver to refault those objects. The result is that these
objects will be refetched from the database the next time they're accessed.
invalidateObjectsWithGlobalIDs
in class EOObjectStore
gids
- An array of globalIDs identifying objects whose snapshots to discard.EOObjectStore.invalidateAllObjects()
,
EOObjectStore.refaultObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)
,
EOEditingContext.invalidateObjectsWithGlobalIDs(com.webobjects.foundation.NSArray)
,
EODatabaseContext.invalidateObjectsWithGlobalIDs(com.webobjects.foundation.NSArray)
public void invalidateAllObjects()
InvalidatedAllObjectsInStoreNotification
, as well as an ObjectsChangedInStoreNotification
with the globalIDs for the invalidated objects in the userInfo
dictionary. Both of these notifications are defined in EOObjectStore. This method works by invoking invalidateObjectsWithGlobalIDs
for all of the snapshots in the receiver's EODatabase.
invalidateAllObjects
in class EOObjectStore
EODatabaseContext.invalidateObjectsWithGlobalIDs(NSArray gids)
,
EOObjectStore
public void batchFetchRelationship(EORelationship relationship, NSArray objects, EOEditingContext editingContext)
relationship
pointed by the source objects in objects
and performs a single, efficient fetch or, at most, two fetches if the relationship is many-to-many. Throws an exception if any of the objects in objects
doesn't
originate from the same entity as relationship
.
This method provides a way to fetch the same relationship for multiple objects. For example, given an array of Employee objects, this method can fetch all of their departments with one round trip to the server, rather than asking the server for each of the employees' departments individually.
relationship
- An EORelationship.objects
- An array of source objects for relationship
.editingContext
- The EOEditingContext.
IllegalStateException
- if anything in objects
doesn't originate from the same entity as relationship
.public NSArray objectsForSourceGlobalID(EOGlobalID gid, String name, EOEditingContext context)
gid
is located and the EORelationship named name
is used to construct a qualifier from that snapshot. This qualifier is then used to fetch the requested objects into the editing context
context
using the method objectsWithFetchSpecification
.
Throws an exception in the following conditions:
gid
does not specify a valid source object in context
.name
is not a valid relationship in the model.gid
.
objectsForSourceGlobalID
in class EOObjectStore
gid
- The globalID to identify the source object.name
- The name of the EORelationship.context
- The EOEditingContext into which to fetch the requested object.
IllegalStateException
- if context
does not contain an object with the globalID gid
, or ifname
is not a valid relationship in the model, or if there is no snapshot for gid
.EODatabaseContext.objectsWithFetchSpecification(EOFetchSpecification fetchSpec, EOEditingContext context)
public boolean ownsGlobalID(EOGlobalID globalID)
true
if the receiver is responsible for fetching and saving the object identified by globalID
, false
otherwise. The receiver is responsible if globalID
is a subclass of EOKeyGlobalID and if globalID
has an
entity from a model belonging to one of the receiver's EODatabases.
ownsGlobalID
in class EOCooperatingObjectStore
globalID
- The unique identifier for an enteprise object.
true
if the receiver is responsible for fetching and saving the object identified by globalID
.EODatabaseContext.handlesFetchSpecification(EOFetchSpecification fetchSpec)
,
EODatabaseContext.ownsObject(EOEnterpriseObject object)
public boolean ownsObject(EOEnterpriseObject object)
true
if the receiver is responsible for fetching and saving object
, false
otherwise. The receiver is responsible if the entity corresponding to object
can be found in a model belonging to one of the receiver's EODatabases.
ownsObject
in class EOCooperatingObjectStore
object
- An Enterprise Object.
true
if the receiver is responsible for fetching and saving object
.EODatabaseContext.handlesFetchSpecification(EOFetchSpecification fetchSpec)
,
EODatabaseContext.ownsGlobalID(EOGlobalID globalID)
public boolean handlesFetchSpecification(EOFetchSpecification fetchSpecification)
true
if the entity identified by the entity name in fetchSpecification
can be found in one of the models owned by the EODatabase of the receiver, false
true,
the receiver is responsible for fetching the objects specified
in fetchSpecification
.
handlesFetchSpecification
in class EOCooperatingObjectStore
fetchSpecification
- The criteria to select and order a group of database records.
true
if the receiver is responsible for fetching
the objects described fetchSpecification
.EODatabaseContext.ownsObject(EOEnterpriseObject object)
,
EODatabaseContext.ownsGlobalID(EOGlobalID globalID)
public void prepareForSaveWithCoordinator(EOObjectStoreCoordinator coordinator, EOEditingContext editingContext)
editingContext
that are owned by the receiver. This method is invoked before the object graph is analyzed and foreign key assignments are performed. Throws an exception in the following
conditions: editingContext
.editingContext
's objects could not be found in the database.
You should never need to invoke this method directly; it is invoked by the Framework.
prepareForSaveWithCoordinator
in class EOCooperatingObjectStore
coordinator
- The EOObjectStoreCoordinator.editingContext
- The current EOEditingContext.
IllegalStateException
- if the receiver is currently performing a save for another editing context, or if it could not obtain primary keys for an associated entity.
EOObjectNotAvailableException
- if the database row for one of editingcontext
's objects is missing.public void recordChangesInEditingContext()
This method is typically invoked in the course of an EOObjectStoreCoordinator saving changes through its saveChangesInEditingContext
method. It is invoked after prepareForSaveWithCoordinator
and before ownsGlobalID
.
You should never need to invoke this method directly.
recordChangesInEditingContext
in class EOCooperatingObjectStore
EODatabaseContext.prepareForSaveWithCoordinator( EOObjectStoreCoordinator coordinator , EOEditingContext editingContext)
,
EODatabaseContext.ownsGlobalID(EOGlobalID globalID)
public void recordUpdateForObject(EOEnterpriseObject object, NSDictionary changes)
changes
supplied from another EOCooperatingObjectStore (through the EOObjectStoreCoordinator) to the database operation for object
in the receiver. For example, an insert of an object in a relationship property might require changing a foreign key
property in an object owned by another cooperating object store. This method can be invoked any time after prepareForSaveWithCoordinator
and before ownsGlobalID
.
recordUpdateForObject
in class EOCooperatingObjectStore
object
- The object for whose database operation changes
will be applied.changes
- Array of changes to apply for object
, supplied from another database context.EODatabaseContext.prepareForSaveWithCoordinator(EOObjectStoreCoordinator coordinator, EOEditingContext editingContext)
,
EODatabaseContext.ownsGlobalID(EOGlobalID globalID)
public void performChanges()
recordChangesInEditingContext
and recordUpdateForObject
. Invokes the delegate method databaseContextWillOrderAdaptorOperations
to give the delegate an opportunity to
construct alternative adaptor operations from the database operations. Then invokes the delegate method databaseContextWillPerformAdaptorOperations
to let the delegate substitute its own array of EOAdaptorOperations. Performs the EOAdaptorOperations on an available
EOAdaptorChannel.
If the save succeeds, updates the snapshots in the receiver to reflect the new state of the server. Throws an exception if the adaptor is unable to perform the operations. The exception's userInfo
dictionary contains these keys:
Key (String Constant) | Value |
DatabaseContextKey |
The EODatabaseContext object that was trying to save to its underlying repository when the exception was thrown. |
DatabaseOperationsKey |
The list of database operations the EODatabaseContext was trying to perform when the failure occurred. |
FailedDatabaseOperationKey |
The database operation the EODatabaseContext failed to perform. |
The userInfo
dictionary may also contain some of the keys listed in the method description for the EOAdaptorChannel method performAdaptorOperation
.
You should never need to invoke this method directly.
performChanges
in class EOCooperatingObjectStore
EOAdaptorChannel
,
EODatabaseContext.commitChanges()
,
EODatabaseContext.rollbackChanges()
,
EODatabaseContext.recordChangesInEditingContext()
,
EODatabaseContext.recordUpdateForObject(EOEnterpriseObject object, NSDictionary changes)
public void cleanupSnapshots()
public void commitChanges()
ObjectsChangedInStoreNotification
is posted describing the committed changes. Throws an
exception if the adaptor is unable to commit the transaction; the error message indicates the nature of the problem.
You should never need to invoke this method directly.
commitChanges
in class EOCooperatingObjectStore
EODatabaseContext.ownsGlobalID(EOGlobalID globalID)
,
EODatabaseContext.rollbackChanges()
public void rollbackChanges()
rollbackChanges
in class EOCooperatingObjectStore
EODatabaseContext.ownsGlobalID(EOGlobalID globalID)
,
EODatabaseContext.commitChanges()
public NSDictionary valuesForKeys(NSArray keys, EOEnterpriseObject object)
keys
from the snapshot of object
. The returned values are used primarily by another EODatabaseContext to extract foreign key properties for objects owned by the receiver.
valuesForKeys
in class EOCooperatingObjectStore
keys
- Array of keys whose values to return from the snapshot for object
.object
- An Enterprise Object.
keys
from the snapshot for object
.
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |