This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Pipeline as Code and have Mohamed Labouardy on-line!
See this thread for details.
Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Callbacks & Transactions in Stateful EJBs

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See a quote from 'Mastering EJB 3.0' below, it's about callbacks in Stateful EJBs:

You don’t need to worry about providing methods annotated as Pre
Passivate and PostActivate callbacks unless you are using open
resources, such as socket connections or database connections, that must be
reestablished after activation.
NOTE The following rules apply to the life-cycle callback methods:
....
■■ They must not throw application exceptions, but may throw runtime
exceptions. If thrown within a transaction, it will cause the transaction
to roll back.



From what I understand, if transaction is open Stateful EBJs are never passivated. Am I missing anything?

 
Greenhorn
Posts: 24
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
The State diagram of the statefull Session bean is the most complicate of all other Beans.
If the Business method is called in a transaction the Statefull goes in a "Method ready in TX" and the Passivate functionality is not available.
There are some other callback annotation that You could Use:
AfterBegin, BeforeCompletion, AfterCompletion.

Please take a look to the EJB spec at page 89

Hope this could be usefull.

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andriy Kharchuk wrote:

From what I understand, if transaction is open Stateful EBJs are never passivated. Am I missing anything?



As massimiliano cattaneo already mentioned the SFSB life cycle is the most rich one. Here is a nice state diagram that may help to understand it:

http://sqltech.cl/doc/oas10gR31/web.1013/b28221/img/lifesfsb.gif
 
This tiny ad is wafer thin:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic