Announcement Announcement Module
Collapse
No announcement yet.
How can I specify default value of @Transactional.timeout? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I specify default value of @Transactional.timeout?

    How can I specify default value of the transaction timeout declaratively?
    I am using <tx:annotation-driven>, DataSourceTransactionManager and iBATIS.

  • #2
    If its annotation driven, then I don't think you can do this declaratively. Check this out.
    http://www.springframework.org/docs/...ional-settings

    Indicates that transaction configuration is defined by Java5 annotations on bean classes, and that proxies are automatically to be created for the relevant annotated beans.

    Transaction semantics such as propagation settings, the isolation level, the rollback rules, etc. are all defined in the annotation metadata.
    http://www.springframework.org/schem...ing-tx-2.0.xsd

    Comment


    • #3
      Isn't it inconvenient?
      I should copy and paste it?
      Or, should I give up the easiness of <tx:annotation-driven>?

      Comment


      • #4
        Originally posted by slopetown View Post
        Isn't it inconvenient?
        I should copy and paste it?
        Or, should I give up the easiness of <tx:annotation-driven>?
        I would agree it is inconvienient, have you checked JIRA to see if there is an issue raised against this? It would be nice to specify defaults and then override them on the annotation. If there isn't an issue raised already might be an idea to raise one!

        Its really upto you, do you think theres that much difference using either one. Does the benefits of one, outweigh the other.

        Comment


        • #5
          Thank you very much for your answers.
          I checked JIRA and raised this issue.
          http://opensource.atlassian.com/proj...rowse/SPR-2974

          Comment


          • #6
            One way of saving typing would be to put it at the class level, the other which I'm not so sure about, would be to put it on an interface and then get every service to implement it.

            Comment


            • #7
              Originally posted by karldmoore View Post
              One way of saving typing would be to put it at the class level, the other which I'm not so sure about, would be to put it on an interface and then get every service to implement it.
              Indeed, but remember that annotating an interface with the @Transactional annotation is not recommended.

              The Spring team's recommendation is that you place the @Transactional annotation on the concrete class (or method of a concrete class), as opposed to on any interface(s) that the class may implement. You certainly can place the @Transactional annotation on an interface, but this will only work as you would expect it to if you are using interface-based proxies. Because annotations are not inherited it means that if you are using class-based proxying then the transaction settings will not be recognised by the class-based proxying infrastructure and the object will not be wrapped in a transaction proxy (which would be decidedly bad). So please do take the Spring teams's advice and use the @Transactional annotation on concrete classes.

              As to the issue of this thread, sounds like a good improvement. We'll see what Juergen thinks

              Cheers
              Rick

              Comment


              • #8
                Originally posted by Rick Evans View Post
                Indeed, but remember that annotating an interface with the @Transactional annotation is not recommended.
                I would agree (I did read the reference manual cover to cover honest). It was just a possible to work round the solution.

                Originally posted by Rick Evans View Post
                As to the issue of this thread, sounds like a good improvement. We'll see what Juergen thinks
                I think he's fixed this one already! Just need to be able to specify defaults for all the other values now, but thats been picked up in another issue.

                Comment


                • #9
                  Originally posted by karldmoore View Post
                  I would agree (I did read the reference manual cover to cover honest). It was just a possible to work round the solution.
                  Aye, I just wanted to be clear about it. I have also cleaned up the language in the wee snippet of the referenece manual that I posted because it was a bit flowery.

                  Originally posted by karldmoore View Post
                  I think he's fixed this one already! Just need to be able to specify defaults for all the other values now, but thats been picked up in another issue.
                  Man, that Juergen guy is so hot right now!

                  Cheers
                  Rick

                  Comment


                  • #10
                    Originally posted by Rick Evans View Post
                    Aye, I just wanted to be clear about it. I have also cleaned up the language in the wee snippet of the referenece manual that I posted because it was a bit flowery.
                    I can't praise the reference manual enough, you guys have done a great job! Now we have to encourage people to read it .

                    Originally posted by Rick Evans View Post
                    Man, that Juergen guy is so hot right now!
                    Hmmmm, I know jealousy isn't an attractive trait, but are him and Costin the only people in world can fit 35 hours in a day.

                    Comment


                    • #11
                      On a related matter, what's the reason for the warning to only place @Transactional on public methods?

                      Comment

                      Working...
                      X