• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

p228 in HF EJB (sessionContext)

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ejbCreate(), ejbRemove().
For stateful bean, it can use SessionContext to get a transaction reeference and call methods on it (BMT bean).
However, it's not case for stateless bean. Do you know the reason? I think stateless bean can access BMT transaction,too. It should be mistake in the book. Am I right?
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The EJB spec says the same thing [p90]. I find it confusing too, but I like to convince myself that because stateless SB's are not tied to client calling create(), remove() there is no meaningful transaction context when the container calls ejbCreate(), ejbRemove(). On the other hand, stateful SB's tie ejbCreate() with a client call. Not sure if this is really true but I'll use that to help me remember.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ejbCreate and ejbRemove runs in unspecified tx context in case of session bean. So no point calling getUserTransaction or getRollbackOnly, setRollbackOnly here.
 
Nishant Verma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nishant Verma:
ejbCreate and ejbRemove runs in unspecified tx context in case of session bean. So no point calling getUserTransaction or getRollbackOnly, setRollbackOnly here.



Above methods will throw IllegalStateException. Applies to **CMT** only. However BMT session bean can start transaction in ejbCreate, ejbRemove. Because BMT EJB's dont care about the container - however smart

 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i will use the 1st answer to help me remember ^_^
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic