Which statement is true about the EJB 3.0 stateful session bean?
A. Its conversational state is retained across method invocations but not across transactional boundaries.
B.Its conversational state is retained across method invocations and transactions.
Given answer: B.
In JSR 318 , it does says B. So, I agree that B is the right answer.
But I have a question:
The EJB container does not support nested transactions , how can the bean's conversational state can be across multiple transactions?
Also, in JSR 317, it also mentions that a stateful bean's transaction can be propagated to a second stateful bean. The persistence context is propagated from the first bean to the second bean.
This refers to only one transaction with the same persistence context being extended from one stateful bean to another stateful bean.
How can a conversation be across multiple transactions?
I can answer my question.
Method 1 of a stateful bean completes a transaction. Then, method 2 is run with a different transaction. The conversation state from the first transaction can be propagated from transaction 1 of method 1 to transaction 2 of method 2.
Method 1 of a stateful bean completes a transaction. Then, method 2 is run with a different transaction.
Yes, you are right.
The conversation state from the first transaction can be propagated from transaction 1 of method 1 to transaction 2 of method 2.
The converstational state is reflected by the instance variables of a stateful session bean. Both methods (for example running in different transactions) can change the instance variables.
EJB 3.1. specification reference:
4.1 Overview Typically, a session object’s conversational state is not written to the database. A session bean developer simply stores it in the session bean instance’s fields and assumes its value is retained for the lifetime of the instance. A developer may use an extended persistence context to store a stateful session bean’s persistent conversational state. See the document "Java Persistence API" of this specification
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.