korma / Korma

Tasty SQL for Clojure.
http://sqlkorma.com
1.48k stars 222 forks source link

Adds a parameter for ConnectionCustomizerClassName #229

Closed ls4f closed 9 years ago

ls4f commented 10 years ago

I found myself needing to change the default isolation level for transactions. After a few hours of experimenting, I finally was left with only one acceptable solution - to provide a ConnectionCustomizerClassName to the c3p0 pool. The parameter should contain the name of a class which implements the ConnectionCustomizer interface.

As an example - here`s the class I use

(ns tara.customizer
  (:gen-class
   :name tara.Customizer
   :extends com.mchange.v2.c3p0.AbstractConnectionCustomizer))

(defn -onAcquire
  [this #^java.sql.Connection connection ^String token]
  (.setTransactionIsolation connection java.sql.Connection/TRANSACTION_REPEATABLE_READ))