Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

How to determine transaction attribute of methods of sub-class in case of method overriding.

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

EJB 3.1 Specification

13.3.7.1 Specification of Transaction Attributes with Metadata Annotations



If the bean class has superclasses, the following additional rules apply.

1. A transaction attribute specified on a superclass S applies to the business methods defined by S. If a class-level transaction attribute is not specified on S, it is equivalent to specification of TransactionAttribute(REQUIRED)on S.
2. A transaction attribute may be specified on a business method M defined by class S to override for method M the transaction attribute value explicitly or implicitly specified on the class S.
3. If a method M of class S overrides a business method defined by a super-class of S, the transaction attribute of M is determined by the above rules as applied to class S

The example provided in the above section is :



Solution:Assuming aMethod, bMethod, cMethod are methods of interface A, their transaction attributes are
REQUIRED, SUPPORTS, and REQUIRES_NEW respectively.

Question:How is transaction attribute of aMethod is "REQUIRED" ?
As per my understanding,since super class has SUPPORTS transaction attribute ,then all its methods will have the same Transaction Attribute
and aMethod of class Abean that overrides the aMethod of class SomeClass has no transaction attribute specified ,then aMethod transaction attribute should be SUPPORTS .
 
Creator of Enthuware JWS+ V6
Posts: 3390
311
Android Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Question:How is transaction attribute of aMethod is "REQUIRED" ?


As aMethod() is overriden it wil get the default transaction attribute of REQUIRED. Only inherited methods (like bMethod()) get the SUPPORT transaction atribute.

Regards,
Frits
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Frits,

Thanks for the reply.
 
reply
    Bookmark Topic Watch Topic
  • New Topic