Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
  • Piet Souris

HFEJB - Session Beans Question

Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a few questions ....
(1) Why we cannot either force a trasaction to rollback (CMT) or findout if a trasnaction has been set to rollback only in ejbCreate for stateful session beans ?
(2) Also if I can access my JNDI Environment in setSessionContext() why I cannot
- access another bean's methods ?
- access a resource manager (like database)

Thanking in advance

Posts: 3062
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. The ejbCreate() method doesn't run in a valid transactional context. The spec doesn't do much to explain why not, except to say that it would unnecessarily complicate the life cycle of the stateful session bean. I'm willing to accept this explanation. Unlike an entity bean, which usually has to write an entry to a database as part of its create process, a stateful session bean just needs to populate its state variables. It might need to read data from a database, either directly or through other beans, but it would never need to alter any data during the creation process. If it doesn't alter data, then it doesn't need a transaction.

2. setSessionContext(), and all the other setXxxxContext() methods, are just part of the setup process for the bean. They can be used to store values and references to objects that will be used later, but shouldn't be used to do any real work. Usually they are just used to store a reference to the context in the bean instance for later use. However, you could also store a reference to the Home interface, or set up the values and object references configured in the bean's environment. You can't actually use these object references until later in the life cycle, but at least you can get them ready.
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
Low Tech Laboratory
    Bookmark Topic Watch Topic
  • New Topic