Announcement Announcement Module
Collapse
No announcement yet.
Transaction Implementation ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction Implementation ?

    Hi Guys,

    I have a bit of a weird question. We have our application running on Spring 2.0 with JTA (Hibernate + Atomikos) for Oracle + IBM MQ. I have just completed the Transactions Chapter of "Spring in Action" and am trying to find how the transactions are handled in our application. I do not find anything as said in the chapter. Here is the info I have :

    1. Processing Transactions using annotations is enabled in our application(<tx:annotation-driven />). But I do not find the @Transactional annotation for out classes / methods.

    2. All URLs are mapped using SimpleUrlHandlerMapping with the parent as "org.springframework.web.servlet.handler.AbstractH andlerMapping". This has an interceptor : org.springframework.orm.jpa.support.OpenEntityMana gerInViewInterceptor. I have read that this allows lazy loaded objects to be used in views. Not sure if I have understood it correctly.

    That is all what I could find. The application behaves as if every request is handled in one whole transaction. But I cannot find where is it written so. Which other places do I need to look for ?

    I am willing to share more info for this investigation - but please let me know what else is required.

    Thanks for your time,
    Midhun

  • #2
    I suggest a read of the tx chapter of the spring reference guide... @Transactional and tx:annotation driven is just one of the ways to configure transactions. There are more ways...

    1) Configure a TransactionProxyFactoryBean for each of your service
    2) Configure a ProxyFactoryBean with a TransactionINterceptor for each of your service
    3) Configure a AutoProxyCreator with a pointcut that matches your services
    4) Confgure aop:config with tx:advice
    5) Do it manually with TransactionTemplate
    6) Do it manually with the PlatformTransactionManager

    So there are more ways that lead to Rome...

    2. Correct but you could also use the OpenEntityManagerInViewFilter instead of the interceptor. But that has NOTHING to do with starting/stopping a transaction!

    Comment


    • #3
      Hi Marten,

      I have tried reading through the chapter again and also the reference documentation on Spring's website. But I could find nothing that I could relate to.

      I read that OpenEntityManagerInViewFilter is used to bind the entity manager to the thread executing the request so that the session is available during the rendering of the View. I am still wondering if this is what starts the transaction as I can find nothing more in our configuration.

      1) Configure a TransactionProxyFactoryBean for each of your service - No reference to this in any config XML files.
      2) Configure a ProxyFactoryBean with a TransactionINterceptor for each of your service - No reference to this in any config XML files.
      3) Configure a AutoProxyCreator with a pointcut that matches your services - No reference to this in any config XML files.
      4) Confgure aop:config with tx:advice - only <tx:annotation-driven />. No <tx:advice> to configure advice for methods. No <aop:config>.
      5) Do it manually with TransactionTemplate - Not used at all.
      6) Do it manually with the PlatformTransactionManager - Not used at all.


      I am also wondering if the JTA transaction manager (Atomikos) plays any role in starting / stopping the transactions. Let me know if you think any one of this is right.

      Thanks for the inputs,
      Midhun.

      Comment


      • #4
        Trust me there is something that drives transactions (at least I hope for you or else you rely on auto commit which I wouldn't recommend)...

        I read that OpenEntityManagerInViewFilter is used to bind the entity manager to the thread executing the request so that the session is available during the rendering of the View. I am still wondering if this is what starts the transaction as I can find nothing more in our configuration.
        OpenSessionInViewFIlter/-INterceptor has NOTHING to do with starting/stopping a transaction! It has to do with keeping a session (or EntityManager open).

        JTA could be managing transactions if you use a MDB or SessionBean to drive your application, that way it could be that the container is in control and not spring, however you state that you use atomicos so I find it hard to believe that it is driven by a MDB or SessionBean.

        Maybe you can post your configuration.

        Comment


        • #5
          Hi Marten,

          Thanks for trying to help me out. I have attached the applicationContext files. Hope this helps...

          Midhun

          Comment


          • #6
            i have the same porblem and can▀t fix it....

            Comment


            • #7
              From the context I see

              1) tx:annotation-driven (can you post some code/interfaces for services/dao
              2) a TransactionTemplate which could indicate manual transaction management, wrapping method calls in a transaction.

              Comment


              • #8
                I have already solved, thanks

                Comment


                • #9
                  Got it !!!

                  Hi Marten,

                  I got to know how all this happens . Each of our URL is mapped to a inteceptor via Spring's AbstractHandlerMapping. This interceptor takes in the transactionManager bean and contains code which starts a transaction in the "preHandle" method and commits or rollbacks the transaction in "afterCompletion" method.

                  It has been a great exercise to find this.

                  Thanks a lot for all the help.
                  Midhun.

                  Comment

                  Working...
                  X