Win a copy of Pipeline as Code this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

SessionSynchronization interface & session bean

 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why can't a a STATELESS session bean implement the javax.ejb.SessionSynchronization interface ?
so can stateful session bean do that?
 
Bartender
Posts: 3697
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SessionSynchronization interface is used to notify bean of transaction state when transaction is spreaded over several methods calls.
Obviously, stateless bean can NOT have transaction which is spreaded over a couple of methods, because once method was called, stateless bean goes to pool and there is no chance to say for sure that next method will be called by the same client.
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mikalai !!!
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mikalai Zaikin:
SessionSynchronization interface is used to notify bean of transaction state when transaction is spreaded over several methods calls.


For SessionSynchronization, the transaction needs to be started always by the client?
SessionSynchronization is used only for CMT and transactions can spread across several methods only in BMT?
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vish Kumar,
The concept of SessionSynchronization interface is there because it gives a stateful bean a chance to synchronize itself with any persistent data that it deals with.
For example if a stateful session bean has a persistent field, then inside afterBegin() it will be appropriate to load the current value from the database.
afterCompletion() should be used to store the persistent field, if the transaction was comitted sucessfully.
Thanx
RUF SCJP
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by J Johny Rufus:
Hi Vish Kumar,
The concept of SessionSynchronization interface is there because it gives a stateful bean a chance to synchronize itself with any persistent data that it deals with.
For example if a stateful session bean has a persistent field, then inside afterBegin() it will be appropriate to load the current value from the database.
afterCompletion() should be used to store the persistent field, if the transaction was comitted sucessfully.
Thanx
RUF SCJP



And SLSB do not maintain state.
 
And inside of my fortune cookie was this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic