Can someone clarify this please? What do they mean by a consistent state?
I don't understand that if a method is not in a transaction why is it not in a consistent state?
Which method can access an enterprise bean in a consistent manner for a container managed stateful session bean that implements the SessionSynchronization interface?
1. constructor()
2. setSessionContext()
3. ejbCreate()
4. beforeCompletion()
5. afterCompletion()
Answer 4 is correct. beforeCompletion() informs a session bean instance that the current transaction is about to be committed. Since the bean instance has a transactional context, the behaviour of executing beforeCompletion() is guaranteed by the container.
Answers 1, 2, 3 and 5 are incorrect. The constructor(), setSessionContext(), ejbCreate(), and afterCompletion() methods are executed with an unspecified transaction context; hence, the behaviour of executing the methods cannot be relied on.
Note: The table 2 on page 80 on
EJB specification states that an enterprise bean may be accessed in the ejbCreate method; however, since a transaction context is unspecified for this method, the behaviour of executing ejbCreate() is not guaranteed by the container