[jboss-user] [JBoss Seam] - Re: What is the difference between EJB and POJO transactions

christian.bauer@jboss.com do-not-reply at jboss.com
Sat Apr 21 02:15:29 EDT 2007


I haven't read the book, but the three basic transaction models are

- EJB/CMT: You have EJB components (session beans, MDBs) and you call these EJB components from whatever other code. By default, a system transaction will begin when an EJB method is called and it will be committed when that method returns. The transaction propagates into other calls, e.g. if your EJB calls another EJB. You can use annotations or XML metadata to change this default transaction assembly. Seam can emulate this behavior with the Seam-specific and proprietary @Transactional annotation on POJOs, then Seam acts as the container that manages transaction boundaries.

- JTA: You can call the JTA UserTransaction API in your application code somewhere and control the begin and end of a transaction programmatically.

- Seam-managed JTA: Seam will call the JTA API for you automatically during the JSF lifecycle, meaning it will wrap two transactions around a JSF request. One transaction starts when the request hits the server and is committed when INVOKE APPLICATION is complete. The second transaction spans only the RENDER RESPONSE phase. This is an optimized and recommended pattern in a Seam/JSF application. All EJBs and indeed any POJOs you call during that request are participating in that transaction. To enable it, configure JSF with the TransactionalSeamPhaseListener.

I recommend the last option, since it works with whatever components you execute and it is good from a scalability perspective. Also, you don't need to write any code or use any annotations with it.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4039495#4039495

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4039495



More information about the jboss-user mailing list