java - Hibernate自定义ExceptionMapper

标签 java hibernate logging

有没有办法创建我自己的 Hibernate ExceptionMapper 而不是使用 ExceptionMapperStandardImpl?我的日志中出现错误,我想获取堆栈跟踪,但标准 impl 只打印出异常消息。

这是我遇到的错误

[io-9010-exec-17] o.h.i.ExceptionMapperStandardImpl : HHH000346: Error during managed flush [Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1]

我尝试向所有 Controller 端点添加日志记录,但似乎无法找到此异常的来源。我知道异常意味着什么(一个数据库对象同时被多个事物更新),但我无法追踪发生这种情况的代码路径。

我没有收到任何其他日志记录。

最佳答案

如果您只是尝试在本地进行调试,您可以在 ExceptionMapperStandardImpl 类上断点,或者在您的实现中通过 copy-pasting from the hibernate source 覆盖它。放入源代码中的 org.hibernate.internal 包

关于java - Hibernate自定义ExceptionMapper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51559319/

相关文章:

java - 仅删除文本区域中的选定文本

java - 从 Fragment 控制套接字输入流和输出流 (Android)

java - 使用 SSL 加密和 NTLM 身份验证的 HttpClient 失败

java - Spring + Hibernate 延迟加载错误

python - 自 2.5 版以来日志记录的变化

java - IntelliJ - 包 org.springframework.stereotype 不存在

java - 如何编写一个通过hibernate插入而没有任何依赖的通用类

java - RunTimeException 是什么原因?

ruby-on-rails - 如何在我的 ruby​​gem 中写入将在 Rails 应用程序中使用的日志?

php - Cakephp 3 无法从插件加载类