This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: setRollbackOnly(boolean) and unsetEntityContext()
 
jQuery in Action, 3rd edition