• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stateful convensation is transactional or not?

 
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
On Frit's notes, p.20, it says stateful session bean instance conversational state is not transactional.
However, on p.21, the life cycle diagram of a stateful bean shows a "method in transaction" , "commit", "rollback".....

So, is the stateful session bean instance conversation transactional or not?
 
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

So, is the stateful session bean instance conversation transactional or not?


No, it is not.

Check EJB specs section 4.2 and 4.2.2
The conversational state describes the conversation represented by a specific client/session object pair, meaning:
  • the instance’s field values,
  • its associated interceptors and their instance field values,
  • the objects that can be reached from these instances’ fields.

  • This session bean instance conversational state is not transactional. It is not automatically rolled back to its initial state if the transaction in which the object has participated rolls back. You should use the afterCompletion() notification to manually reset the conversational state in case of a rollback.
     
    Himai Minh
    Bartender
    Posts: 2419
    13
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Frits. Thanks for your reply.
    I think I understand it now.

    1. Conversational state means the instance variables, interceptor's variables that are not transactional. That means these variables are not necessarily used in a transactional context by default.

    2. But we can still define a transaction using REQUIRED, REQUIRED_NEW, MANDATORY attributes to commit these variables or rollback them.
     
    Frits Walraven
    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

    2. But we can still define a transaction using REQUIRED, REQUIRED_NEW, MANDATORY attributes to commit these variables or rollback them.


    No.

    When these variables change during a method call, and there is a need of a rollback, all the database updates and/or JMS interaction will be rolled back. You as a developer have to manually reset these variables into the state they were before the method call was invoked.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic