File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Transaction doesn't rollback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Transaction doesn Watch "Transaction doesn New topic
Author

Transaction doesn't rollback

Vince Chen
Greenhorn

Joined: Sep 11, 2004
Posts: 14
Dear all:
My Spring configuration is as follows:
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/oraclekom" />
</bean>

<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>

<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="doDelete*" />
<tx:method name="doUpdate*" />
<tx:method name="doInsert*" />
<tx:method name="move*" />
</tx:attributes>
</tx:advice>

<aop:config>
<aop ointcut id="vdmServiceMethods" expression="execution(* tw.com.yl.vdm.bso.*BSO.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="vdmServiceMethods"/>
</aop:config>


I have a method in class "VD15BSO.java" under package "tw.com.yl.vdm.bso" whose method name is "doUpdateJobChecksFromExcel". This method would access two tables via dao object. First dao deletes and inserts data into database,
and second dao occurs error while it inserts data into database. The delete and insert action of first dao won't rollback.

Does anyone know that where my configuration is wrong?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

I never use AOP for transaction management. I use annotation based transaction configuration. So in my applicationContext.xml I have:

<tx:annotation-ddriven transaction-manager="transactionManager" />

And my service classes have @Transaction on the methods. Everything rolls back and commits just fine.


GenRocket - Experts at Building Test Data
Vince Chen
Greenhorn

Joined: Sep 11, 2004
Posts: 14
But my runtime environment is jdk 1.4.x. It cannot use annotation, is it?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by Vince Chen:
But my runtime environment is jdk 1.4.x. It cannot use annotation, is it?


That is true.
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Vince,

compare your config to: http://www.springframework.org/docs/Spring-MVC-step-by-step/part6.html#step6.4
Note that the "ProductManager" there is an interface.

And did you check your logs for errors?

Herman
Ryan Nowak
Greenhorn

Joined: Dec 06, 2007
Posts: 4
I would second Herman's advice, turn logging on DEBUG and watch the logs. Does it begin a transaction? If not then something in your aop configuration is wrong.
Anirban Chowdhury
Ranch Hand

Joined: Aug 05, 2008
Posts: 36
Please also provide the service methods. What persistence f/w are you using?


To living life on the edge! I blog my experiences @ http://anirbanchowdhury.wordpress.com.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transaction doesn't rollback