wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes setRollbackOnly(boolean) and unsetEntityContext() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "setRollbackOnly(boolean) and unsetEntityContext()" Watch "setRollbackOnly(boolean) and unsetEntityContext()" New topic
Author

setRollbackOnly(boolean) and unsetEntityContext()

Eric Lemaitre
Ranch Hand

Joined: Jul 03, 2004
Posts: 538

Hi all !

It is unclear to me what the role of boolean in "setRollbackOnly(boolean)" is, I believed ask a rollback to Container was made once for all, so "setRollbackOnly()" as in UserTransaction was enough.
What is more why is there "unsetEntityContext()" for Entity Beans, while no "unsetSessionContext()" for Session Beans ? For Stateless Beans obviously no use at all but not in Stateful case.

Best regards.


Eric LEMAITRE
CNAM IT Engineer, MS/CS (RHCE, RHCX, SCJA, SCJP, SCJD, SCWCD, SCBCD, SCEA, Net+)
Free Online Tutorials: http://www.free-tutorials-online.net/
Paul Maessen
Greenhorn

Joined: Sep 27, 2004
Posts: 12
Hi Eric,

Take a look at http://java.sun.com/products/ejb/docs.html: there is no setRollbackOnly(boolean) on EJBContext.

As for unsetEntityContext: if the container removes a *session* bean from the pool it calls ejbRemove on the bean prior to the removal.

But this can't be done for entity beans since creation/removal have a different meaning: ejbRemove is called prior to removing the physical entity itself (not the bean). The bean (now without an idenity) goes back into the pool. If the container decides it doesn't need the bean anymore it will call an additional callback method 'unsetEntityContext' to inform the bean of its intention.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setRollbackOnly(boolean) and unsetEntityContext()
 
Similar Threads
BMP bean
mock exam question
unsetEntityContext and no unsetSessionContext
Doubt on which type of bean to choose
unsetSessionContext