Advanced users may need to access an editing context’s access layer or adaptor layer objects. To access an editing context’s access layer objects, you get an editing context’s object store coordinator and the object store coordinator’s database context object. From the database context object, you can get the database context’s adaptor-level objects.
An editing context can have more than one set of access layer and adaptor layer objects, so you need to identify which set you’re looking for. You can do this a number of ways: with a fetch specification, with a global ID, or with an enterprise object. The code in “Listing 5-2” uses a fetch specification to help the root object store determine which of its cooperating object stores can service your request.
Listing 4-2 Accessing lower-level objects
EOEditingContext editingContext; //Assume this exists. |
EOFetchSpecification fetchSpec; |
EOObjectStoreCoordinator rootObjectStore; |
EODatabaseContext databaseContext; |
EOAdaptor adaptor; |
EOAdaptorContext adaptorContext; |
fetchSpec = new EOFetchSpecification(entityName, null, null); |
rootObjectStore = (EOObjectStoreCoordinator)editingContext.rootObjectStore(); |
databaseContext = (EODatabaseContext)rootObjectStore.objectStoreForFetchSpecification(fetchSpec); |
adaptor = databaseContext.database().adaptor(); |
adaptorContext = databaseContext.adaptorContext(); |
Last updated: 2007-07-11