Announcement Announcement Module
Collapse
No announcement yet.
Hibernate3 to Hibernate2 Transaction propagation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate3 to Hibernate2 Transaction propagation

    Hi,

    I'm trying to call a method that is wrapped in hibernate 2 transaction (org.springframework.orm.hibernate.HibernateTransa ctionManager) from a method wrapped in hibernate 3 transaction. Both of the methods have PROPAGATION_REQUIRED as a transaction attribute. If there is a runtimeexception in hibernate3 transaction method, the hibernate2 transaction method passes(i.e. it persists the data). However, I don't want this to happen. I would like both the methods to be in one transaction and if there is any exception in any method, I don't want data to be persisted.

    Details:

    I have 2 context files for hibernate3 and hibernate3 with the follwing configurations.

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory"><ref bean="sessionFactory"/></property>
    </bean>

    <!-- bean id="transactionManagerForAclObjectPermissionDelete " class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory"><ref bean="sessionFactoryForAclObjectPermissionDelete"/></property>
    </bean -->

    <bean id="matchAllWithPropReq" class="org.springframework.transaction.interceptor .MatchAlwaysTransactionAttributeSource">
    <property name="transactionAttribute"><value>PROPAGATION_REQ UIRED</value></property>
    </bean>

    <bean id="matchAllTxInterceptor" class="org.springframework.transaction.interceptor .TransactionInterceptor">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributeSource"><ref bean="matchAllWithPropReq"/></property>
    </bean>

    <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="interceptorNames">
    <list>
    <idref bean="matchAllTxInterceptor"/>
    </list>
    </property>

    <property name="beanNames">
    <list>
    <idref bean="userClientService"/>
    </list>
    </property>
    </bean>


    -----------
    config for hibernate2 transaction
    -----------------------

    <bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
    <property name="sessionFactory"><ref bean="localSessionFactoryBean"/></property>
    </bean>

    <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate.Hibernate Interceptor">
    <property name="sessionFactory"><ref bean="localSessionFactoryBean"/></property>
    </bean>

    <bean id="matchAllWithPropReq" class="org.springframework.transaction.interceptor .MatchAlwaysTransactionAttributeSource">
    <property name="transactionAttribute"><value>PROPAGATION_REQ UIRED</value></property>
    </bean>

    <bean id="matchAllTxInterceptor" class="org.springframework.transaction.interceptor .TransactionInterceptor">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributeSource"><ref bean="matchAllWithPropReq"/></property>
    </bean>

    <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="interceptorNames">
    <list>
    <idref bean="exceptionTranslator"/>
    <idref bean="matchAllTxInterceptor"/>
    <idref bean="hibernateInterceptor"/>
    </list>
    </property>
    <property name="beanNames">
    <list>
    <idref bean="userService"/>
    </list>
    </property>
    </bean>
Working...
X