Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

MDBs in transactions - 2 questions

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Joyce for the quick and detailed answer.
Xavier
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic