Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction doesn't rollback

 
Vince Chen
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vince Chen
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But my runtime environment is jdk 1.4.x. It cannot use annotation, is it?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please also provide the service methods. What persistence f/w are you using?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic