• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Transaction in Session Bean

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am preparing for the SCBCD and planning to sit for the exam on the Java Certification Day here in Singapore. I have got a doubt as below.

Referring to page 207 of HeadFirst EJB, under the list of use your session context to i could find 'get a transaction reference and call methods on it (BMT Beans)'. But methods on CMT like force a transaction to rollback and find out whether a transaction has already been rolled back could not be called. How can this be explained? When a bean is in a transaction it cannot be passivated. Isn't this applies to both CMT and BMT? Thanks for any replies..

Kuppusamy
SCJP 1.3
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I know the answer to the second question: Stateful session beans can only keep a transaction open over more than one method invokation when using BMT. With CMT, the transaction has to be completed within the method. Since the container will not attempt to passivate the bean while it is in the middle of a business method (but only when the bean has not been used for some time), this problem will not occur with CMT.

Hope that's correct & helps...

Greets,
Stefan
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi SamyV,

I think the answer for your question is on page 499 of HF EJB.
CMT session bean methods ejbCreate(), ejbRemove(), ejbActivate() and ejbPassivate() run in an "unspecified transaction context".
In other words, the create and remove methods os session bean are not considered part of client's transaction and activate and passivate will never be called if the session bean is in a trasaction.
Remember it is true for CMT session beans.
I hope this helps you.

Vagner
reply
    Bookmark Topic Watch Topic
  • New Topic