• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Unspecified, but meaningful transaction?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LS,

The following confused me while reading the EJB 2.0 specs. In 7.5.7 it states that a session bean's ejbCreate and ejbRemove are called within an unspecificied transaction. In 7.6.1 I read that accessing resource managers and enterprise beans is dissallowed in the session bean's methods for which the Container does not have a meaningful transaction context. But the table on page 80 allows accessing resource managers and enterprise beans in the ejbCreate and ejbRemove methods. Does this mean that an unspecified transaction is a meaningful transaction?

thanks,
Mark
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

[I have edited my answer regarding stateful session beans]

The transaction context in ejbCreate and ejbRemove depends on the type of bean you are looking at. For entity beans, the containers call to the ejbCreate and ejbRemove methods is related to the client call and can therefore participate in the caller�s transaction and therefore access resource managers other enterprise beans etc. For stateless session beans and message driven beans the containers call to the ejbCreate and ejbRemove methods is not related to a client call and can therefore not participate in the caller�s transaction, in other words the transaction context is unspecified, i.e. you cannot write code that depends on a transaction being present.

For stateful session beans the transaction is also unspecified in ejbCreate and ejbRemove but the explanation given above does not apply here because the containers call to ejbCreate and ejbRemove is related to the client call. The spec gives the following reason (page 76)
-----
�. The ejbCreate and ejbRemove methods are not controlled by a transaction attribute because handling
rollbacks in these methods would greatly complicate the session instance�s state diagram. �.
-----
So for statefull session beans you can access resource managers and enterprise beans in ejbCreate and ejbRemove in a way that do not depend on a transaction being present.

Kind regards
Christian
[ July 09, 2004: Message edited by: Christian Sellberg ]
 
Mark Hoogenboom
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Christian. Your explanation makes a lot more sense than the remarks in 7.5.7 and 17.6.5 about the transaction context of a session bean's ejbCreate en ejbRemove methods.

kind regards,
Mark
reply
    Bookmark Topic Watch Topic
  • New Topic