Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

MDBs in transactions - 2 questions

 
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
 
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
 
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic