UnexpectedRollbackException - 完整的场景分析 [英] UnexpectedRollbackException - a full scenario analysis

查看:530
本文介绍了UnexpectedRollbackException - 完整的场景分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个例外是Spring的

从Spring的文档中:


尝试提交事务导致意外回滚时抛出


我想一次性了解


  1. 究竟是什么原因?




    • 回滚发生在哪里?在App Server代码或数据库中?

    • 是否由于特定的基础异常(例如java.sql。*中的某些内容)导致?

    • 是否与Hibernate相关?是否与Spring Transaction Manager(在我的情况下是非JTA)有关?


  2. 如何避免? / strong>有什么最佳做法可以避免吗?


  3. 如何调试?似乎很难复制,任何经过验证的方法解决方案


解决方案

在日志中滚动一点点(或增加它的缓冲区-size),你会看到究竟是什么造成的例外。



如果没有发生,请查看 getMostSpecificCause() getRootCause()方法 UnexpectedRollbackException - 它们可能很有用。


All I know about this exception is from Spring's documentation and some forum posts with frostrated developers pasting huge stack traces, and no replies.

From Spring's documentation:

Thrown when an attempt to commit a transaction resulted in an unexpected rollback

I want to understand once and for all

  1. Exactly what causes it?

    • Where did the rollback occur? in the App Server code or in the Database?
    • Was it caused due to a specific underlying exception (e.g. something from java.sql.*)?
    • Is it related to Hibernate? Is it related to Spring Transaction Manager (non JTA in my case)?
  2. How to avoid it? is there any best practice to avoid it?

  3. How to debug it? it seems to be hard to reproduce, any proven ways to troubleshoot it?

解决方案

Scroll a little more back in the log (or increase it's buffer-size) and you will see what exactly caused the exception.

If it happens not to be there, check the getMostSpecificCause() and getRootCause() methods of UnexpectedRollbackException- they might be useful.

这篇关于UnexpectedRollbackException - 完整的场景分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆