• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stateful convensation is transactional or not?

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • 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?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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
    Ranch Hand
    Posts: 1361
    7
    • Mark post as helpful
    • send pies
    • 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
    Saloon Keeper
    Pie
    Posts: 2536
    113
    Android Chrome Eclipse IDE
    • Mark post as helpful
    • send pies
    • 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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic