• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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 ^_^
 
reply
    Bookmark Topic Watch Topic
  • New Topic