• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MDBs in transactions - 2 questions

 
Xavier Fabreguettes
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
In the Headfirst book, it is said that for MDBs you are not allowed to:-
- attempt to start a BMT transaction from within another one (i.e. have 2 nested userTransaction.begin() calls)
- attempt to return from a method before the BMT transaction is finsished (i.e. return before calling userTransaction.commit() (or rollback())
I'm OK with that but my question is what would happen if you tried to to what is described above? The book just says not to do it but does not explain what the consequence would be. Would an IllegalStateException be thrown?
Thanks,
Xavier
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- attempt to start a BMT transaction from within another one (i.e. have 2 nested userTransaction.begin() calls)

The Container will throw javax.transaction.NotSupportedException in the
begin() method. Refer to EJB 2.0 spec 357.
- attempt to return from a method before the BMT transaction is finsished (i.e. return before calling userTransaction.commit() (or rollback())

The Container will log the error, rollback the transaction and discard the bean. Refer to EJB 2.0 spec 356.
Joyce
 
Xavier Fabreguettes
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Joyce for the quick and detailed answer.
Xavier
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic