Win a copy of Fixing your Scrum this week in the Agile forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

deployment descriptor transaction attributes

 
Ranch Hand
Posts: 477
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSR:220
13.3.7.2 Specification of Transaction Attributes in the Deployment Descriptor states the following:

If the deployment descriptor is used to override annotations, and transaction attributes are not specified for some methods, the values specified in annotations (whether explicit or defaulted) will apply for those methods.



Is there ever a time when transaction attributes are not specified (and/or defaulted)? Annotated transaction attributes aren't overridden by transaction attributes in the deployment descriptor under what conditions exactly? If possible, could you please provide any (simple and) concrete examples to help clarify?

 
Bartender
Posts: 2111
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On p.174 of EJB in Action (2nd edition), It says " REQUIRE is the default..." which means @TransactionAttribute.REQUIRED is the default.
 
Charles O'Leary
Ranch Hand
Posts: 477
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

13.3.7.2 Specification of Transaction Attributes in the Deployment Descriptor

The following is the description of the rules for the specification of transaction attributes in the deployment
descriptor. (See Section 19.5 for the complete syntax of the deployment descriptor.)

Note that even in the absence of the use of annotations, it is not necessary to explicitly specify transaction
attributes for all of the methods listed in section 13.3.7. If a transaction attribute is not specified for
a method in an EJB 3.1 deployment descriptor, the transaction attribute defaults to Required.

If the deployment descriptor is used to override annotations, and transaction attributes are not specified
for some methods, the values specified in annotations (whether explicit or defaulted) will apply for
those methods.



In the context of the above, what's meant by the following:


If the deployment descriptor is used to override annotations, and transaction attributes are not specified
for some methods, the values specified in annotations (whether explicit or defaulted) will apply for
those methods.




More specifically:

Is there ever a time when transaction attributes are not specified (and/or defaulted)? Annotated transaction attributes aren't overridden by transaction attributes in the deployment descriptor under what conditions exactly? If possible, could you please provide any (simple and) concrete examples to help clarify?

 
Himai Minh
Bartender
Posts: 2111
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When transaction attribute is not specified, then, by default, it is @TransactionAttribute(TransactionAttributeType.REQUIRED).

On p.416 of EJB in Action(2nd),


You used @TransactionAttribute to specify that the transaction attribute for a bean method be REQUIRE_NEW. If you want to override it to use REQUIRED, then use the following descriptor:
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>BazaarAdmin</ejb-name>
<method-name>getUserWithItems</method-name>
<method-params></method-params>
</method>
<transaction-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>

 
Charles O'Leary
Ranch Hand
Posts: 477
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Himai Minh,

I agree with your answers for your specific example. I am NEVER a big fan of the specifications. Where's Head First? (Sorry, I digressed.) Since they are the standard by which these exams are judged and possibly because it's late, unfortunately, I'm not connecting your example with my specific questions. If you have the patience, please help me connect the dots.


Ranchers,

My (possibly erroneous) interpretation is that the values specified in annotations (whether explicit or defaulted) will apply for
those methods INSTEAD OF the values specified in the deployment descriptor under certain conditions?

AND there are numerous contradictions in MY understandings within this one sentence of the specification:

* Since when did annotations override deployment descriptor?
* Because of defaults (REQUIRED in this case), what does it mean for a transaction attribute to be simply "unspecified" (or not defaulted)?
* ".... specified in annotations (whether explicit or defaulted) will apply ..." But, in the same sentence it says that somehow "transaction attributes are not specified"?

 
Creator of Enthuware JWS+ V6
Posts: 3395
312
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Charles,

I understand your confusion. The specifications are not always easy to read. Let me try to simplify things for you:

  • Transaction attributes in the deplyment descriptor always override the transaction attributes in annotations.
  • It is possible to override one method of a certain EJB in the deployment descriptor. If you do so, the other methods wil have the value of the annotation, or if not specified they will get the default: REQUIRED.
  •  
    Charles O'Leary
    Ranch Hand
    Posts: 477
    9
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Got it! Thanks Frits Walraven and Himai Minh!
     
    Don't play dumb with me! But you can try this tiny ad:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic