JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java Application Framework » Spring  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
作者 請教有關TransactionManager的commit
uxa





發文: 489
積分: 6
於 2009-02-25 11:49 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
請教一下小弟在某一個method中當有Exception發生時要做commit
將其設定為PROPAGATION_REQUIRED, +java.lang.Exception
但是當我在執行時遇到Exeption後spring卻丟出以下的訊息
1
2
3
4
5
6
7
org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
  at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:672)
  at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:357)
  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
  at $Proxy4.paymentProc(Unknown Source)


我將DataSourceTransactionManager的log打開來看到這樣的訊息
1
2
3
4
2009-02-25 11:38:45,312 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager.processRollback:805]- Participating transaction failed - marking existing transaction as rollback-only
2009-02-25 11:38:45,312 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager.doSetRollbackOnly:286]- Setting JDBC transaction [jdbc:oracle:thin:@10.1.5.224:1521:o9idb, UserName=TEST, Oracle JDBC driver] rollback-only
2009-02-25 11:38:45,312 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager.commit:666]- Global transaction is marked as rollback-only but transactional code requested commit
 


請教一下是什麼情況下會將Transaction設置為rollback only呢
有其他的方式可以達到有Exception時commit嗎


reply to postreply to post
☆只要努力就有希望☆
作者 Re:請教有關TransactionManager的commit [Re:uxa]
koji

秒速5センチメートル

站長

發文: 8415
積分: 19
於 2009-02-25 22:10 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
所以你如果沒發生exception
就會順利commit嗎?

koji


reply to postreply to post
JCConf Taiwan 2015 開始售票了!!
Facebook上的TWJUG社團,歡迎加入
作者 Re:請教有關TransactionManager的commit [Re:uxa]
uxa





發文: 489
積分: 6
於 2009-02-26 11:07 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
小弟昨天找到原因了...
因為我想要A method在有Exception時commit
但是A method裡面會去呼叫另一個類別的B method
而B method卻設成有Exception時rollback,導致在Exception出現時我的A method會無法做commit的動作


reply to postreply to post
☆只要努力就有希望☆
» JWorld@TW »  Java Application Framework » Spring

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8