您的位置:首页 > 其它

<org manual>翻译--3.5.7 编辑和调试公式

2013-05-27 22:08 323 查看
ERROR TransactionInterceptor:307 - Application exception overridden by commit exception

错误原因可能为:

Remember only unchecked exceptions cause rollbacks in spring transactions.

What is happening is that you're catching the unchecked exception, converting it to a checked exception and then propogating it. The transaction manager does not rollback for RecordExistsException and thinks that your first transaction has succeded. Thats why it tries to save your child objects. You should annotate your service with 

Code:
[code]@Transactional (rollbackFor= RecordExistsException.class)


or have your exception class extend RuntimeException.[/code]
解决办法:

OK, the way I read that an exception occurs and it does indeed do a commit. I would presume there must be a rollback rule defined telling it to do this.

Before Spring2.0 might look like this.

<prop key="*">PROPAGATION_REQUIRED, -com.mydomain.exception.MyException</prop>
 http://www.springframework.org/docs/reference/transaction.html#transaction-declarative-txadvice-settings[/code] 
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: