简体   繁体   English

JPA在一个事务中进行多次提交

[英]JPA Multiple commit within one transaction

Can I have multiple commits within one JPA transaction ? 我可以在一次JPA交易中进行多次提交吗? I'm using JPA with Hibernate. 我正在使用JPA和Hibernate。 Correct me if I'm wrong but commit won't end the transaction ? 如果我错了,请纠正我但提交不会结束交易? Thanks for replay. 谢谢你重播。

A transaction is a context created within the execution environment that groups multiple commits (and/or DML operations on a database) in one execution unit - if one goes wrong, all the work done in this transaction context is discarded. 事务是在执行环境创建的上下文 ,它在一个执行单元中对多个提交(和/或数据库上的DML操作)进行分组 - 如果出错,则丢弃在此事务上下文中完成的所有工作。

So in short: you can have multiple operations in one transaction, only when you commit that transaction those changes are applied to database. 简而言之:您可以在一个事务中拥有多个操作,只有在您提交该事务时,这些更改才会应用于数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM