• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transaction and EJB Handle

 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As i know all system level exception thrown will caused trasaction to be rolled back. However, if a user defined exception occured, is it necessary to roll back the transaction or could it just be ignored. If ignored, will it cause problems?

If we look up the home interface will the container passivate it? For statefull session beans, it is possible that the container passivate and then reactivate the Ejb. I don't understand if it is the bean, home or remote that gets passivated. Can someone kindly explained it to me please? When we deal with ejb is it wise to keep reference to the bean through its handle?
for session ejbs, everytime we call create, its up to the container to determined if one is really created, the container could decide to activate one and tailor it specific to the requested need. is that right?
Thanks a lot
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an Application Exception occurs (this includes a CreateException, DuplicateKeyException, FinderException, ObjectNotFoundException, and RemoveException) the transaction is not automatically rolled back. If you need to have the exception rolled back then you must do it yourself. If it makes sense for the transaction to commit then do nothing.
To passivate a home interface does not make sense. The home interface is just a factory to create an EJBObject. For this reason you can save and reuse Home Interfaces to avoid the lookup.
For stateful session beans it is the EJB Bean instance that gets passivated. For more details I suggest you get a copy of Enterprise Java Beans by Richard Monson-Haefel or a copy of Mastering EJB by Ed Roman and company. Here is a link to the free pdf download.
 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chris
Is it a good idea to hold the handle or home handle of an ejb or ejb home instead of just a reference to the home and the ejb itself? Any advice are welcomed. Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!