在JPA中,本机查询是否会发生回滚?
我使用 JPA 1.0 和 hibernate 作为我的提供程序。在entitymanager事务内部,如果运行一系列本机查询(包括DELETE sql语句)并且发生错误,本机查询也会在错误时回滚吗?
我在 Oracle 数据库中遇到了死锁问题,我注意到即使某些事务已回滚,它也会使数据库不一致。我想知道不一致是否是由于一个事务成功但另一个事务回滚但仅回滚到某个点的事实造成的?
谢谢..
I'm using JPA 1.0 with hibernate as my provider. Inside an entitymanager transaction, if a series of native queries are run (which include DELETE sql statements) and an error occurs, will the native queries rollback too on the error?
I ran into a deadlock problem in an oracle database and I noticed that it left the database inconsistent even though some of the transaction was rolled back. I'm wondering if the inconsistency resulted from the fact that one transaction succeeded but the other transaction rolled back but only up to a certain point?
Thanks..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
回滚不会具体回滚“JPQL 查询”,它会回滚 SQL 语句,这包括来自“本机查询”的 SQL 语句。
A rollback doesn't rollback "JPQL queries" specifically, it rollbacks SQL statements and this includes SQL statements from "native queries".
是的。发生错误时,JPQL 和本机 SQL 查询将回滚。
Yes. The JPQL and native SQL queries are rolled back when an error occurs.