Forums Register Login

Will HibernateTransactionManager rollback jdbc transactions?

+Pie Number of slices to send: Send
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.
Would you like to try a free sample? Today we are featuring tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1008 times.
Similar Threads
HibernateDaoSupport and Transaction
Trouble converting a Spring JDBC app to use Spring Hibernate
Trouble converting a Spring JDBC application for Spring with Hibernate
Exception on Save operation with Spring annotation
I am getting org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity:
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:20:42.