Win a copy of Functional Design and Architecture this week in the Functional programming 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:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Transaction Attributes

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Page 351 of the EJB 2.0 Specs, it is stated that "Transaction attributes must not be specified for the methods of a session bean�s home interface."
However, we can specify trans. attributes for the methods of an entity bean's home.
Why is this difference ?
thanks
vipin
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vipin,
When you invoke create or remove on a stateless session bean - it doesn't necessarily mean that the server invokes the corresponding ejbCreate or ejbRemove on the bean instance. So seen in that perspective it doesn't make any sence to allow for the client to specify TX behavior.
However, with entity beans, it is another story. When you invoke create, remove etc. on an entity beans home interface it actually means that something is happening in the database (according to the containers strategy this can postponed to TX commit time, etc.). If that wasn't under your TX control then it wouldn't be reliable (or useful at all).
Hope it gives you a "logical" view on those two different cases.
 
Bartender
Posts: 3725
39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey, Nicky !
excellent explanation !
 
Vipin Mohan
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Nicky
Thanks for the answer. However, I still have a question. A client call to create() does not cause a call to ejbCreate(), this is only for stateless session beans. What about stateful beans then ? For them create() and remove() are delegated to the bean's ejbCreate() and ejbRemove() methods. So should't transaction attributes be set for these methods in the case of stateful session beans ?
Thanks
Vipin
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, there are could be no need for session beans to use transcation at all( though they might). For example, a stateful session bean could be just a calcualtor without ever calling the database.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by calvin zhu:
well, there are could be no need for session beans to use transcation at all( though they might). For example, a stateful session bean could be just a calcualtor without ever calling the database.


-Say if I have a SFSB that does some database updating activity in the ejbCreate()/ejbRemove() method and if the method throws a runtime exception, my transactions are still committed
As the methods execute in an unspecified transaction context, can I assume that the container will likely perform a rollback operation in the above scenario?
 
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