• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring AOP vs Annotation based Tx Management

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are starting a new project and want to follow the best practices.

Which one is better either Spring AOP or Annotation based for the Tx Management.

Spring AOP - in this tx management will be defined in xml file only. And only xml file can be modified to manage the transactions.
Annotation based - Here we specify the transaction with @Transactional in the Java Code. In this approach transactions are all over in the Java Code.

I was able to see both the approaches in many places in internet. So got confused.

Any suggestions are helpful. Thanks in advance.

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a limited set of pointcuts - list all them in aop advice in xml config.
If in each case you want to make individual decision - use Transactional annotation on the corresponding methods of corresponding beans.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally, of all places, this is the one where I highly recommend using Annotations as to me, it is so much easier. Especially because I can put @Transactional on the class level and now all methods of my interface in that class are now transactional. And to configure that in xml takes a lot more typing.

Mark
 
Boris Romashov
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:And to configure that in xml takes a lot more typing.


As I wrote, if you have a limited set of pointcuts, configuring this in xml is will take less typing.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Boris Romashov wrote:

Mark Spritzler wrote:And to configure that in xml takes a lot more typing.


As I wrote, if you have a limited set of pointcuts, configuring this in xml is will take less typing.



But I doubt the method names follow naming conventions and if I have a limited set, means I have a limited amount of classes, so just @Transactional at the class level and now I can see it is transactional in one place, the class and not have to go between two different files to see the whole setup.

Mark
 
Kand ron
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the @transcational is at the Class level. If the application is having many classes where @transactional is kept. Then there is a chance of developers messing with the @transactional and putting some attributes like readonly, propagation. And it will become uncontrollable and inconsistent in the application? And if it is the on config file, it can be tracked easily by going to the xml file.

please let me know your thoughts?

Thanks in advance.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kand ron wrote:If the @transcational is at the Class level. If the application is having many classes where @transactional is kept. Then there is a chance of developers messing with the @transactional and putting some attributes like readonly, propagation. And it will become uncontrollable and inconsistent in the application? And if it is the on config file, it can be tracked easily by going to the xml file.

please let me know your thoughts?

Thanks in advance.



And if they mess with it in the XML and add lots of attributes for lots of methods the XML is way tougher to maintain. Having to do lots of pointcuts and tx namespace for attributes. It is very disjointed and to me annoyingly difficult to maintain.

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic