On 05/02/2012 09:46 AM, Durchholz, Joachim wrote:
No, a DataContext is a context within which retrieving the same rows via some query will always give you identical Java objects. That's a pretty powerful (and important) property, but not necessarily related to a connection. (Connections become important as soon as you need transaction-related guarantees.) You don't need to create an ObjectContext to work with a DataContext - any DataContext already is an ObjectContext. You don't roll back a database transaction here, you roll back to whatever was last loaded from the database. If you use child contexts, you can roll back to whatever the state was when that child context was started. I believe that this means that you may have data loaded in different transactions in your application, and that that is the price you pay for getting rid of LazyInitializationExceptions. (True Cayenne experts, please correct if that's wrong. I'm writing this both to help Andrew along and to get helped along ;-) )
One thing I found that I must create at least one ObjectContextChild before the DataContext becomes usable otherwise I'm not seeing the connection being made to the database in the log files. I'm using Cayenne 3.0.2 and an Oracle database. I can provide a log trace if required.


Reply via email to