Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

sessionSynchronization

 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why can't statless bens implement sessionSynchronization?

Can BMT Session beans implement sessionSynchronization? It would be pointless but can they?

Can EntityBeans implement sessionSynchronization?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Kris Reid:
Why can't statless bens implement sessionSynchronization?
Can BMT Session beans implement sessionSynchronization? It would be pointless but can they?
Can EntityBeans implement sessionSynchronization?


1.) Stateless beans cannot implement sessionSynchronization because transactions in stateless session beans are not allowed to span multiple method calls. As soon as a method returns, the transaction is over. Begin/Commit is governed by the scope of the method. There is no more sense to call the sessionSynchronization methods.
2.) They can (im not sure) but might not be called by the container since it expects the bean provider to explicitly call begin and commit.
3.) Entitiy beans have onLoad() and onStore() methods instead of the sessionSynchronization methods. I'm not sure if implementing is legal. I doubt it.
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why can't stateless beans implement SessionSynchronization?


By allowing stateless session beans to implement SessionSynchronization, we're actually implying that session beans can maintain state across transactions, which is not true. Hence, it is not allowed.

Can BMT Session beans implement SessionSynchronization? It would be pointless but can they?


You can't. Because by having BMT, you know exactly when you're starting & ending the transactions. The exact boundaries of the transactions are made known to you. Hence, you don't have to rely on implementing the SessionSynchronization interface.

Can EntityBeans implement SessionSynchronization?


As of EJB 2.0, entity beans can only be of CMT type. As pointed out by Paul, you've the benefits of ejbLoad & ejbStore. Also, the name of the interface sortof indicated that its meant for session beans only.
 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic