-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Commiting and rollback strategy failure
PostPosted: Wed May 10, 2006 3:19 pm 
Newbie

Joined: Wed Mar 15, 2006 10:40 am
Posts: 3
I am trying to insert rows into two different tables. Can any one please tell me why if an insertion into one table fails, the insertion into another table is not getting rollbacked in Hibernate. My sources are:

Spring Bean Loader
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<bean id="txnManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!--Data Source Properties -->
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<value>Common.hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SybaseDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
<prop key="hibernate.connection.autocommit">false</prop>

</props>
</property>
</bean>

<bean id="manager" class="src.Manager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<bean id="myObject" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="txnManager" />
<property name="target" ref="manager" />
<property name="transactionAttributes" >
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

</beans>

Manager.java
package src;
import java.util.ArrayList;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class Manager extends HibernateDaoSupport {

public void storeValue(ArrayList al, ArrayList al1) {

try {
System.out.println("In storeValue");

SynSeqNumVO oSynSeqNumVO = (SynSeqNumVO) al.get(0);
SynProdTypeVO oSynProdTypeVO = (SynProdTypeVO) al1.get(0);

getHibernateTemplate().save(oSynSeqNumVO);
getHibernateTemplate().save(oSynProdTypeVO);
System.out.println("Saved the Values");
}
catch (Exception e) {
System.out.println("Exception in storValue : "+e);
}
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.