jdbi 中的交易
我使用 jdbi inTransaction() 函数将 sql 查询作为事务执行。我想知道内部如何/使用什么类型的锁定机制。另外,事务期间是锁定整个表还是只锁定需要更新的记录?
I execute sql queries as transactions using jdbi inTransaction() function. I would like to know how/what type of locking mechanism is used internally. additionally, is the whole table locked during the transaction or just the record that has to be updated?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事务纯粹是在数据库级别进行的。除非被覆盖,否则它将使用数据库/连接的默认隔离级别。
如果您使用接受回调的 inTransaction(...) 方法,则该函数有一种形式允许您设置隔离级别:
-Brian
The transaction is purely at the database level. It will use the default isolation level for the database/connection unless overridden.
If you are using the inTransaction(...) method which accepts a callback, there is a form of that function which allows for you to set the isolation level:
-Brian
您的问题的第二部分“...在事务期间锁定整个表还是仅锁定必须更新的记录?”取决于所使用的 DBMS。
例如,以下是有关表级和行级锁定的 MySQL 文档: https://dev.mysql.com/doc/refman/5.7/en/internal-locking.html
The 2nd part of your question, "...is the whole table locked during the transaction or just the record that has to be updated?", depends on DBMS being used.
Here's, for example, MySQL documentation for table- and row-level locking: https://dev.mysql.com/doc/refman/5.7/en/internal-locking.html
这取决于事务隔离级别。 隔离
It depends on transaction isolation level. Isolation