• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

K&B: A question about Transaction

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
thanks
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Rishi
SCJP,SCWCD,IBM OOAD
 
Ranch Hand
Posts: 8953
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
www.onjava.com/pub/d/835
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic