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.
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: