• 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
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

My exam cloud, quiz 3, stateful bean's conversational state across transactions

 
Bartender
Posts: 2301
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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?
 
Himai Minh
Bartender
Posts: 2301
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Acetylsalicylic acid is aspirin. This could be handy too:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic