Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

rollback in SFSB  RSS feed

 
sowmya thiru
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SFSB
you can begin a transaction during ejbCreate() and commit/rollback in another business method
What will be effect when ejbCreate() is part of Txn start, and rollback happens in anotehr method?
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, the EJB Specification explicitly makes a point of not specifying the transactional context for the ejbCreate() lifecycle event of Session Beans (and a few other lifecycle methods). Some Application Servers may allow you to begin a transaction in ejbCreate(), others may not. Therefore, attempting to start a transaction in ejbCreate() of a Session Bean should be avoided if you are looking to create a portable solution.
For more information on this, see 17.6.5 of the EJB 2.0 Specification.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, I am moving this to the EJB Forum...
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some Application Servers may allow you to begin a transaction in ejbCreate(), others may not.

I feel it is a volation of ejb spec.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
I feel it is a volation of ejb spec.

Not at all. It states explicitly in the specification that the behavior is up to the EJB Container.
EJB 2.0 Specification, Section 17.6.5:
The EJB specification does not prescribe how the Container should manage the execution of a method with an unspecified transaction context´┐Żthe transaction semantics are left to the Container implementation.
 
Dragan Milic
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Mathews:
Actually, the EJB Specification explicitly makes a point of not specifying the transactional context for the ejbCreate() lifecycle event of Session Beans (and a few other lifecycle methods). Some Application Servers may allow you to begin a transaction in ejbCreate(), others may not. Therefore, attempting to start a transaction in ejbCreate() of a Session Bean should be avoided if you are looking to create a portable solution.
For more information on this, see 17.6.5 of the EJB 2.0 Specification.

Hallo Chris,
Starting a transaction in the ejbCreate() of the SLSB makes no sense since the instances are pooled. Starting a transaction in the ejbCreate of the SFSB makes sense and is allowed by the EJB 2.0 spec. See the Chapter 7.6.1 (page 80, table 2 - BMT Demarcation).
Dragan
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!