tomekw/hikari-cp

How to set transactionIsolation property?

metametadata opened this issue · 5 comments

Readme at https://github.com/brettwooldridge/HikariCP mentions transactionIsolation but I don't see it in the current wrapper source code. Is this property supported? Thanks.

Hi, have you just tried to set :transaction-isolation datasource property? hikari-cp SHOULD take care of that and translate it to the proper setting. If not, either you or me, we can prepare a patch :)

Thanks!

I've tried :transaction-isolation "TRANSACTION_SERIALIZABLE" with PostgreSQL and it has no effect. Calling (.setTransactionIsolation config "TRANSACTION_SERIALIZABLE") manually works. So I guess the patch is needed, maybe I'll create a request later.

Thanks for reporting the problem, @metametadata. I can confirm that both of the following return nil instead of the desired isolation value.

(-> hikari-cp.core-test/valid-options
    (merge {:transaction-isolation java.sql.Connection/TRANSACTION_SERIALIZABLE})
    (hikari-cp.core/datasource-config)
    (.getTransactionIsolation)) #_=> nil

(-> hikari-cp.core-test/valid-options
    (merge {:transaction-isolation "TRANSACTION_SERIALIZABLE"})
    (hikari-cp.core/datasource-config)
    (.getTransactionIsolation)) #_=> nil

We set the property using addDataSourceProperty and it appears not to behave as expected. Perhaps we need to explicitly call setTransactionIsolation, just as you suggest.

Thanks!

You're welcome! I've just released [hikari-cp "2.8.0"] with the patch included.