Search code examples
jdbctransactionsjdbi

transactions in jdbi


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?


Solution

  • 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:

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

    -Brian