Transactions in jdbi

I execute sql queries as transactions using the jdbi inTransaction () function. I would like to know how / what type of locking mechanism is used internally. Also, is the entire table locked during the transaction, or is it just the record that needs to be updated?

+4
source share
3 answers

The transaction is carried out exclusively at the database level. It will use the default isolation level for the database / connection, if not overridden.

If you use the inTransaction (...) method, which takes a callback, there is a form of this function that allows you to set the isolation level:

<ReturnType> ReturnType inTransaction(TransactionIsolationLevel level, TransactionCallback<ReturnType> callback) 

-Brian

+8
source

It depends on the isolation level of the transaction. Isolation

+1
source

The second part of your question: β€œ... the entire table is locked during a transaction or is it just a record that needs to be updated?” Depends on the DBMS used.

Here, for example, is the MySQL documentation for locking at the table and row level: https://dev.mysql.com/doc/refman/5.7/en/internal-locking.html

0
source

Source: https://habr.com/ru/post/1381561/


All Articles