• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EPractize Lab Answer

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
MyExamCloud Support
Posts: 264
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 264
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Run away! Run away! Here, take this tiny ad with you:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic