|
From: Hemadri N. <hem...@sl...> - 2004-08-19 18:27:35
|
Hi ,
I am having problem in using declarative transaction in spring framework.
the methos i included in the transaction is not rolling back eventhough
there is an exception
I am using ms access as database
my codes are look like as below
TestSpringDao.java my dao class where i get the exception
--------------------------------------------------------------------
public String myQuery()throws Exception,DataAccessException {
String name = "";
try {
jt = new JdbcTemplate();
jt.setDataSource(dataSource);
jt.update("update retiredb set name='test12' where Id=1");
jt.update("insert into spring2 values ('test2','address2')");
}
catch (DataAccessException e)
{
System.out.println("inside exception DataAccessException ------" + e);
throw e;
}
catch (Exception ee) {
System.out.println("inside exception Exception ------" + ee);
throw ee;
}
return name;
my buisiness class from where i am calling the daos perticular method
----------------------------------------------------------------------------
---
public boolean CreateRetirementDataObject(RetirementPlanBean rpb)throws
Exception,DataAccessException {
try {
ts.myQuery();
}
catch (DataAccessException e)
{
System.out.println("inside DataAccessException buisiness class ------" + e);
throw e;
}
catch (Exception e) {
System.out.println("inside exception in buisiness class<<<<<"+e);
throw e;
}
return true;
}
and my xml files are look like this
----------------------------------------
applicationContext.xml
<bean id="testSpring" class="beans.TestSpring">
<property name="dataSource"><ref local="dataSource"/></property>
</bean>
<bean id="retirementBusinessObject" class="beans.RetirementBusinessObject">
<property name="dataAccessObject"><ref local="testSpring"/></property>
</bean>
----------------------------------------------------------------------------
--
dataAcessContext-local.xml
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>
<bean id="senderNewTx"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBe
an">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref bean="retirementBusinessObject"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED,-DataAccessException,-Exception</prop>
</props>
</property>
</bean>
I am getting the exception in catch block of DataAccessException .
Is there is any problem in setting the target for transaction.
what should be the target class which is specifying?
whether It should be the buisiness class from where i am calling the dao
method?
Thanking you,
Biju
|