• 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

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: 3909
43
  • 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: 8945
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic