• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

p228 in HF EJB (sessionContext)

 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • 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?
 
Darien Cheung
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • 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.
 
Nishant Verma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
i will use the 1st answer to help me remember ^_^
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic