Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Frits Walraven
  • Piet Souris

K&B: A question about Transaction

Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, K&B
I am learning EJB now, so exiting that your book has published
I have some questions about transaction in EJB.

1. What the different between "Container managed transaction" and "Database Managed Transaction"? that is what the diff between
"<tans-attribute>Required</trans-attribute>" and "connection.commit()"
,if I just have a singel database. which can provide better perfermance.

2. Is there any different between the transaction in Session bean and Entity bean?

3. If too many nesting transaction declaration in EJBs, for example EJBa call EJBb, and EJBb call EJBc, they all declared transaction required in their calling method,will the container optimize it?
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike
When you say Container Managed Transaction the Container acts as a Transaction Manager , typically it synchronizes the databse operations commit() and rollback with the Transaction Manager whose context it maintains and it invokes the commit and rollback operation depending upon the the result of callback methods which it invokes on the buisnes logic.
Whereas when you say DataBase Managed Transaction it is as good as interacting with the DB directly after getting connected to it . so the idiom of DataBase Managed Transcation as such does not exist in EJB.
Again the REQUIRED attribute is only the way to notify the container that a trnsaction context should be present, either by the client , if not it has to be initiated by the container and a commit() is a physical assurance of a operation being dealt against the DB.
Typically the transaction will be present only in Session bean bcoz we write the bizlogic here the Entity bean are only suppose to represent Records or rows in database. The container does optimizes calls to various EntityBeans if they are cached, typicall y we use proven patterns for the same like Aggregate Entity Bean or with the local interfaces with EJB2.0 we can achive a local tranparency which was not there till 1.1 and which definately was a overhead.
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic