Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HFEJB - Session Beans Question

Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • 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: 3036
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
  • 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.
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic