Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transactions with Statefull Bean

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is reason behind "only session bean with BMT can keep transaction open at the end of a method"?
 
Andor Nemeth
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by gowher amin naik:
what is reason behind "only session bean with BMT can keep transaction open at the end of a method"?


Only STATEFUL session beans with BMT can keep a transaction open at the end of a method!
Remember, stateless and message driven beans(MDBs) are pooled, so two method calls to these types of beans might be served by two different instances! That's why transactions should be closed (commited/rolled back) before your method ends.

If you have a STATEFUL bean, then you have a "conversational state". Every method call will be served by the same instance, therefore with BMT it's possible to keep transactions open between method calls!

If you have container managed transaction(CMT), then all the transactions will last for the time of a method call. They begin when your method starts, and end when your method ends. This is maintained explicitly by the container.

Correct me if i was wrong!
Andor N�meth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic