• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

afterBegin() method

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which method can be invoked when a stateful session bean is in the method ready state but not in a transaction?

A ejbCreate()
B afterBegin()
C ejbActivate()
D afterCompletion()
E beforeCompletion()


This is one of the question in the sun's practice exam. Accroding to them the answer is B.

But isn't the afterBegin() method invoked by the container method after it starts a transaction ?

Or is there a better explanation for the answer
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Will Hunt:
Which method can be invoked when a stateful session bean is in the method ready state but not in a transaction?

A ejbCreate()
B afterBegin()
C ejbActivate()
D afterCompletion()
E beforeCompletion()


This is one of the question in the sun's practice exam. Accroding to them the answer is B.

But isn't the afterBegin() method invoked by the container method after it starts a transaction ?

Or is there a better explanation for the answer



The question is tricky. However, I would go by exclusion. It cannot be A & C because the bean is already in the method-ready state. It cannot be D & E because a transaction is supposed to be already started...By exclusion it bust be B, because it is the only method that remains, and it's likely that for a CMT SB, the method will run in a transaction.

HTH,

Marco
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From Mastering Entriprise Javabeans: " Called by the container directly after a transaction begins"

From HF-EJB: "At the beginning of a stateful bean's transaction, BEFORE the business methods that's going to run in the trasnaction is called"

From EJB spec: The afterBegin notification signals a session bean that a new transaction has begun. The container invokes this method before the first business method within a transaction (not nec. the beginning)

When the container invokes afterCompletion(boolean committed), is the ready state?
[ July 31, 2004: Message edited by: Ryan Wong ]
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic