Win a copy of Fixing your Scrum this week in the Agile forum!
  • 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
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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

 
Bartender
Posts: 2111
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: 2111
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: 3395
312
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

 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic