aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Transaction Attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Transaction Attributes" Watch "Transaction Attributes" New topic
Author

Transaction Attributes

Vipin Mohan
Ranch Hand

Joined: Nov 15, 2003
Posts: 79
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
Nicky Moelholm
Ranch Hand

Joined: Jan 20, 2002
Posts: 43
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.


Nicky Moelholm
MyCerts: SCJP 1.2, SCJP 1.5, SCJD, SCWCD 1.3, SCBCD 1.3, SCDJWS 1.4, SCEA, IBM 253
MyBooks: IBM WebSphere Application Server V7.0 Web Services Guide
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3211
    
    6
hey, Nicky !
excellent explanation !


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Vipin Mohan
Ranch Hand

Joined: Nov 15, 2003
Posts: 79
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
calvin zhu
Ranch Hand

Joined: Mar 18, 2002
Posts: 54
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.


SCEA, SCJD, SCWCD, SCBCD, SCJP<br />IBM WebSphere Portal certification
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
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?
 
 
subject: Transaction Attributes