|
From: Colin S. <col...@ex...> - 2004-08-19 19:48:44
|
This is already an ongoing thread in the support forums. Bringing it
over to the dev list is inappropriate and rude to boot! The dev list is
a place for discussion related to development of Spring itself.
Hemadri Naidu wrote:
>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
>
>
>
>
>-------------------------------------------------------
>SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
>100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
>Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
>http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
|