Most common DataContext use pattern is to create one DataContext per session. "Session" may be a an HttpSession in a web application, or any other similar concept in a multiuser application.
DataObjects are registered with DataContext either implicitly when they are fetched via a query, or read via a relationship from another object, or explicitly via calling {@link #createAndRegisterNewObject(Class)}during new DataObject creation. DataContext tracks changes made to its DataObjects in memory, and flushes them to the database when {@link #commitChanges()}is called. Until DataContext is committed, changes made to its objects are not visible in other DataContexts.
Each DataObject can belong only to a single DataContext. To create a replica of an object from a different DataContext in a local context, use {@link #localObject(ObjectId,Persistent)} method.
For more information see Cayenne User Guide.
Note that all QueryEngine interface methods are deprecated in the DataContext. Since 1.2 release DataContext implements ObjectContext and DataChannel interfaces.
@author Andrus Adamchik
|
|
|
|
|
|
|
|
|
|