Announcement Announcement Module
Collapse
No announcement yet.
best way to set rollbackFor using transaction annotation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • best way to set rollbackFor using transaction annotation

    Hi,

    I am using spring transaction annotation

    <tx:annotation-driven transaction-manager="transactionManager"/>

    and it is causing pain for me to set the rollback flag on each and every file
    (as shown below)

    @Transactional(rollbackFor=Exception.class)

    Is there some way that I can specify this in a central location like my xml using the annotation instead of having to redo it in all my files.

  • #2
    I don't think is possible to have this defined in an xml file. My first idea would be to define this central location as an interface all your transactional class should implement and to override the unwanted rollbackFor=Exception.class for those methods which don't want this behavior.

    Comment


    • #3
      best way to set rollbackFor using transaction annotation

      Hi Stefan,

      I have tried to implement this idea but it seems that annotations can be inherited.

      Is this idea something you managed to get working?

      Please send an example if you can.

      Thanks.

      Comment


      • #4
        Hi,

        I think you should try aop and tx tags in your applicationContext-xxx.xml to set the "rollback-for" property of your transactions.

        Regards,

        Thomas

        Comment

        Working...
        X