Announcement Announcement Module
Collapse
No announcement yet.
Our Spring/Hibernate config executes too many commits & rollback Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Our Spring/Hibernate config executes too many commits & rollback

    In our application (Webapps with Tomcat), we use spring 1.1/hibernate 2 / struts.
    I use P6Spy to check the executed SQL orders.

    For a very sample code :
    1 action call a service which call a DAO to get 1 object from the database.

    Just at the biginning of the service, I see that a commit is executed. => KO, why ?
    Then the select. => OK. that's correct.
    Then after the end of my service, 1 commit and 2 rollbacks are executed. => KO, why ?

    We use a configuration file.
    <!-- HibernateThrowsHandler effectue un flush sur les sessions hibernate-->
    <bean id="myFlushAdvisor"
    class="sopra.twork.dao.hibernate.spring.HibernateF lushAdvice">
    <property name="sessionFactory">
    <ref local="sessionFactory" />
    </property>
    <property name="flush">
    <value>true</value>
    </property>
    </bean>

    <!-- template for the dao Transactional proxy -->
    <bean id="templateDao" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="target"><ref bean="templateDaoImpl"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="delete*">PROPAGATION_REQUIRED ,-DaoException</prop>
    <prop key="save*">PROPAGATION_REQUIRED ,-DaoException</prop>
    <prop key="update*">PROPAGATION_REQUIRED ,-DaoException</prop>
    <prop key="insert*">PROPAGATION_REQUIRED ,-DaoException</prop>
    <prop key="replace*">PROPAGATION_REQUIRED ,-DaoException</prop>
    <prop key="add*">PROPAGATION_REQUIRED ,-DaoException</prop>
    <prop key="create*">PROPAGATION_REQUIRED ,-DaoException</prop>
    <prop key="remove*">PROPAGATION_REQUIRED ,-DaoException</prop>
    <prop key="*">PROPAGATION_SUPPORTS,-readOnly,-Exception</prop>
    </props>
    </property>
    <property name="postInterceptors">
    <list>
    <ref bean="myThrowsAdvisor"/>
    <ref bean="myFlushAdvisor" />
    </list>
    </property>
    </bean>

    <!-- template for the service Transactional proxy -->
    <bean id="templateService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="target"><ref bean="templateDaoImpl"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="find*,get*,select*">PROPAGATION_REQUIRED,-readOnly,-Exception</prop>
    <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
    </props>
    </property>
    <property name="postInterceptors">
    <list>
    <ref bean="myThrowsAdvisor"/>
    <ref bean="myFlushAdvisor" />
    </list>
    </property>
    </bean>
    You will find here the trace file I get :

    1240901217126|-1||debug||commit, statement
    1240901217126|-1||debug||select marque from table1 where oid=?;
    1240901217126|0|4|result|select marque from table1 where oid=?
    1240901217126|-1||resultset|select marque from table1 where oid=1|CODE_MAR3_ = AIXAM, CONSTRUC6_ = AIXAM, LIBELLE_4_ = AIXAM, LIBELLE_5_ = AIXAM
    1240901217126|0|4|result|select marque from table1 where oid=1|CODE_MAR3_ = AIXAM, CONSTRUC6_ = AIXAM, LIBELLE_4_ = AIXAM, LIBELLE_5_ = AIXAM
    1240901217173|-1||debug||rollback, statement
    1240901217282|-1||debug||commit, statement
    1240901217298|-1||debug||rollback, statement
    Thanks for your help.
    Last edited by vincdel; Apr 28th, 2009, 02:51 AM.

  • #2
    OpenSessionInViewFilter might involved in this problem !

    I was just wondering if org.springframework.orm.hibernate.support.OpenSess ionInViewFilter
    might be involved in the fact that the commit/rollback/commit/rollback are executed at the end of the http session (after the mapping.forward)

    Comment

    Working...
    X