• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EPractize Lab Answer

 
Al Purvis
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to get some feedback on a question form EPractize lab that I do not agree with.

The scenario has an EJB1 which has a withdrawal() function with an attributed of Required set. There is another EJB2 with a function that has no transaction context. Both of these call a getAccount() function on a third bean which performs a deduction, some calculations, updates and returns the update value.

The question is how should the transaction attribute be set for the getAccount() function on the called bean. The answer provided is RequiresNew with an explanation that it would require its own transaction.

I disagree and believe it should be Required. I agree that a transaction is required but I would think you would want to continue with the existing transaction not to start another independent one.

Why I am thinking this is that I would want the calling transaction to fail if the getAccount() fails or is rolled back. Would RequiredNew not result in a fail of getAccount() to not have not effect on the calling transaction? Am I out to lunch?
 
Ganesan Ponnusamy
MyExamCloud Support
Ranch Hand
Posts: 264
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "Required" transaction attribute also correct answer if it uses CMP.

Please refer the choices and post your queries to our authors team at scea1exam@epractizelabs.com.

Regards
Ganesan
http://www.epractizelabs.com
[ July 27, 2006: Message edited by: P Ganesan ]
 
Santiago Urrizola
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i agree, required is the correct answer.

The "Required" transaction attribute also correct answer if it uses CMP.

Its true, but if you use BMP you dont make any declarative configuration, so ... required is the correct answer.
[ July 28, 2006: Message edited by: Santiago Urrizola ]
 
Ganesan Ponnusamy
MyExamCloud Support
Ranch Hand
Posts: 264
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In container-managed transaction demarcation, six different transaction attributes--Required, RequiresNew, NotSupported, Supports, Mandatory, and Never--can be associated with an enterprise bean method.

With bean-managed transaction demarcation, an enterprise bean uses the javax.transaction.UserTransaction interface to explicitly demarcate transaction boundaries.

Moreover for transaction handling we should use CMP. Please refer sun's blueprints guidelines.

http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/transactions/transactions7.html


Regards
Ganesan
http://www.epractizelabs.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic