Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB Transactions and Java beans interaction  RSS feed

 
Avianu Sud
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
1) We have a EJB Facade(Stateless Session, with BMT), that will begin and commit/rollback transactions.
The EJB's call Java beans(Not EJB's) which are included in the container, and perform database inserts.
Will the regular Javabeans participate in the transaction and rollback the insert operation?
2) If we use CMT, and the same scenario (Javabeans performing Inserts/updates), will the insert in the Javabean be rolledback?

3) For a EJB based system, there are many Facades (which are typically used by clients). Now facades can call internal plain java classes to perform various DB operations. For these beans to participate in transactions, do they need to be made EJB's also(by extending EJBLocalHome)?
Please discuss some strategies you have used for Transaction support, specially to make the EJB system flexible and resiliant to DB conflicts.
Thanks in advance - Avianu
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For all three scenarios, yes, the database operations are included in the transaction and can be rolled back.
For CMT, the EJB Container rolls back transactions automatically in case a system exception is thrown. You have to catch application exceptions yourself and call setRollbackOnly() on the context object.
 
Vinod John
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just one more thing, the container should be aware (have control over) of the jdbc connection you are using, ie., you should use the db connection from the app server connection pool, in the java bean, to use JTS implementation provided by your app server.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!