• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K&B: A question about Transaction

 
Mike Wang
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?
thanks
 
Rishi Singh
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.
Rishi
SCJP,SCWCD,IBM OOAD
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
www.onjava.com/pub/d/835
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic