【问题标题】:org.hibernate.exception.LockAcquisitionException: could not extract ResultSetorg.hibernate.exception.LockAcquisitionException:无法提取 ResultSet
【发布时间】:2014-08-31 18:29:39
【问题描述】:
我创建了一个休眠会话并为该会话启动了一个事务。
之后,在该会话中对存储过程进行多次调用。在其中一个电话中,我收到了这个错误
org.hibernate.exception.LockAcquisitionException: 无法提取结果集
在所有过程调用之后,事务被提交。
这种情况应该怎么办?
我观察到只有一些条目(与存储过程调用相关)反映在 MySQL 数据库中,而其他条目则没有。
除了对存储过程的失败调用之外,理想的行为不应该是所有条目都反映在数据库中吗?
【问题讨论】:
标签:
java
mysql
sql
hibernate
stored-procedures
【解决方案1】:
我想我无法理解你的真正意思。不过,我还是想说明一些要点,以防它们对您有所帮助。
- 理想情况下,每次数据库通信都在事务中进行。
- hibernate 中的会话不是线程安全对象,每次与数据库通信后都会被丢弃。除非需要,否则会话不会获得 JDBC 连接或数据源。在使用之前不会消耗任何资源。
- 如果事务内部发生任何错误/异常,则在理想情况下整个事务都会回滚。
如果您有嵌套事务
What happens depends on whether this is a nested transaction:
If it is not, then eventually the transaction times out and rolls back.
If it is, the parent transaction will see that a child transaction has not committed when it commits itself. This will result in a rollback of the entire transaction.