[jboss-user] [JBoss Seam] - Re: EntityManager: For newbies or to close gaps in your know
bfo81
do-not-reply at jboss.com
Fri Dec 1 14:06:20 EST 2006
The Extended Persistence Context only says, that the entities "live" in the managed state for multiple method invocations, in opposition to the "normal" Persistence Context, in which the entities get detached after a method has finished.
Transactions are completely indepent from that. And always remember that transactions are an isolated piece of work. Just think of it as football (soccer, not american football, please *g*) matches. Losing one match doesn't mean you can't win the next ;).
There's just one thing you should bare in mind: after a rollback the involved entities might be in a dirty state.
Now, to your question: If you want to have a transaction span multiple method invocations I'd say that you should switch to user managed transactions (instead of container managed ones - there's a certain EJB annotation for that, but at the moment I don't know which one). Then you can start a transaction and finish it later, in another method. But I never did this so don't trust me without testing that yourself ;).
But, I can hear Gavin screaming, "children, don't do this at home" ;). Whenever you have a transaction opened for a longer period, you might have serious problems with scalability. Multiple open transactions may block each other. In a clean software architecture transactions are lasting only a short time.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990533#3990533
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990533
More information about the jboss-user
mailing list