cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Scheibe <>
Subject External transactions...
Date Wed, 16 May 2012 20:47:35 GMT
Hi all,

i'm just in the process of creating a web application bound to cayenne 
in the backend. I'm using external transactions (XA with multiple 
databases) and basically start/commit/rollback a transaction whenever i 
have something to change inside the databases. While this is working 
fine i'm trying to understand the way cayenne behaves regarding the 
object context lifecycle.

Imagine the following use case:


List<Object> objects = querySomeObjectsViaTheObjectContext();

commitTX(); or rollbackTX();

If i understand correctly relationships are not necessary resolved 
directly but lazy when accessed through an object. My question now is 
how does the object context behave when it has to fetch some additional 
objects due to relationships that have to be resolved on access? I mean 
obviously the object context is no longer valid (?) as potentially the 
external transaction manager might have closed it's correspodning 
datasource and returned it back to the connection pool.

However the objects in my list are still available in memory and can be 
used although cannot be modified easily or be committed in the next 
transaction as they of course don't belong to the newly created object 

So what i'm doing right now (and i'm sure i'm missing some important 
facsts as this is a really hack solution) is to create a new 
transaction, requery all the objects i modified and transfer all 
modified attributes to the ones i just got back from the query.

I'd really appreciate some explanation on how you guys approach stuff 
like, i mean it's obvious that i have to store the objects in a user 
interface (showing them in a table or whatever) but cannot keep and 
transaction ongoing as long as the user interface is waiting for some 


View raw message