This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setRollbackOnly(boolean) and unsetEntityContext()

 
Eric Lemaitre
Ranch Hand
Posts: 538
Eclipse IDE Hibernate Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Maessen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic