Hi ... Will HibernateTransactionManager rollback hibernate operations only or will it rollback any operation(like a jdbc insert) on the db.
If it does not rollback jdbc transactions then please let me know as to what could be done to rollback a combination(hibernate/jdbc) of db transactions.
Below is the code that i am using.
----------------------------------------------------------------------------------------------------------------------------------
Transaction.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="save">PROPAGATION_REQUIRED</prop> ------- adding transaction interceptor on all the save methods.
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
----------------------------------------------------------------------------------------------------------------------------------
public void save(Product product){
getHibernateTemplate().save(product);
jdbc call to insert into a table; }
---------------------------------------------------------------------------------------------------------------------------------
public class ProductQohDaoImpl extends HibernateDaoSupport implements ProductQohDao{
public void save(ProductQoh productQoh){
int x = 1/0; ---deliberately throwing an exception to rollback the transactions
getHibernateTemplate().save(productQoh);
}
}
----------------------------------------------------------------------------------------------------------------------------------
Thank you for your help.
If it does not rollback jdbc transactions then please let me know as to what could be done to rollback a combination(hibernate/jdbc) of db transactions.
Below is the code that i am using.
----------------------------------------------------------------------------------------------------------------------------------
Transaction.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="save">PROPAGATION_REQUIRED</prop> ------- adding transaction interceptor on all the save methods.
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
----------------------------------------------------------------------------------------------------------------------------------
public void save(Product product){
getHibernateTemplate().save(product);
jdbc call to insert into a table; }
---------------------------------------------------------------------------------------------------------------------------------
public class ProductQohDaoImpl extends HibernateDaoSupport implements ProductQohDao{
public void save(ProductQoh productQoh){
int x = 1/0; ---deliberately throwing an exception to rollback the transactions
getHibernateTemplate().save(productQoh);
}
}
----------------------------------------------------------------------------------------------------------------------------------
Thank you for your help.