You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by stéphane Lestoclet <st...@yahoo.fr> on 2011/09/13 21:16:24 UTC

Re : Cayenne Transactions

>http://cayenne.apache.org/doc20/understanding-transactions.html 

Thanks for the link. In fact, I already
read almost all the Cayenne documentation
http://cayenne.apache.org/doc/understanding-transactions.html (which I think more recent)

>I use Cayenne in a fairly straight
forward manner, and perform
>transactions explicitly in code
rather than using an AOP approach. 
I understand that Cayenne works but do
you mean that it does not integrate with Spring ?
If so, why the Cayenne documentation
states the opposite ?
Do you also mean that Cayenne
Transactions don't work with J2EE servers ?

>With regard to Spring integration,
Cayenne does not actually need 
OK. That's true. However, what if we
would like to take benefits from the two frameworks.

I think that if it comes to choose
between Spring and Cayenne, Spring will probably win because it's
really an integration framework and it's widely used in production.

>Spring to fill in the gaps like
HIbernate does. 
Sorry, that is not true. We can also
use Hibernate without Spring. We can even use it with plain JSP and
servlets.

Cayenne framework is definitely a good
framework but I think if it's a little bit invasive :
	* persistent entities have to inherit from a cayenne object
	* transactions are made manually and doe not use the standard ones (javax.transaction)

Actually, I'm trying to play with
Cayenne in order to develop a Spring CayenneTransactionManager 
That will allows the use of AOP and
thus to separate the persistent layer from the business one
and especially to hide the persistence
details.

Thanks

Re: Re : Cayenne Transactions

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi,

not sure if you subscribed to the list and receiving the traffic from the list or only the emails cc'd to your address, as there were other replies in this thread. I am cc'ing now, but you may want to check the archive for the ongoing discussion.

On Sep 13, 2011, at 10:16 PM, stéphane Lestoclet wrote:

> I think that if it comes to choose
> between Spring and Cayenne, Spring will probably win because it's
> really an integration framework and it's widely used in production.

I guess the points made here were not about choosing between Cayenne and Spring. There is no such choice. They are complimentary, not competing. I am sure there are hundreds of Cayenne applications built using Spring container. I've done a few myself (although as of lately I am using other DI containers). IMO the comments here were alluding to the patterns of integration even though they may have been worded as "no Spring required" :))

> * persistent entities have to inherit from a cayenne object

I'd say this is a nice alternative to runtime proxies. 

> * transactions are made manually and doe not use the standard ones (javax.transaction)

There has to be a mindset shift here.. Cayenne "transactions" are a different beast and Cayenne apps are therefore often written differently in respect to tx management. They can be "wrapped" in JTA transactions if desired. Most people don't bother, preferring the smooth ride of an ObjectContext (and opt for managing multiple in-memory ObjectContexts instead), but I am sure there are cases when you have no choice. 

I liked the metaphor made previously on this list, about Cayenne being like SVN (or GIT if you consider nested contexts) - you checkout your local copy of the DB, work with it as long as you need without holding any open DB resources (like connections) and then commit your changes when you are ready. 

Even the context rollback, while it implies a tx, is really an in-memory operation of restoring the objects state. Moreover rollback is not required, as ObjectContext doesn't hold to any resources. You can just abandon a context and start a new one.

Andrus