簡體   English   中英

RollbackException:事務標記為rollbackOnly,盡管將其設置為norollbackfor

[英]RollbackException: Transaction marked as rollbackOnly although setting it as norollbackfor

伙計們我有這種方法

 @Component public class Services implements Serializable { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = Exception.class, timeout = -1) public void method() { try { addBean(bean1); } catch (Exception e) { e.printStackTrace(); } addBeans(List<Beans); // Adds Lists of beans editBean(bean1); // Edit first bean "bean1" } } 

但我總是得到org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly ...我嘗試了大量但從未實現的任何幫助?

RollbackException是RuntimeException,因此不是派生自Exception。 但我懷疑RuntimeException的norollback不會有所幫助,因為原因可能是其他原因。 可能是超時,樂觀鎖定問題,重復的唯一ID,...可能發生回滾的原因很多,而這些原因與引發的異常無關。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM