From 298c689a734358c381f55748041d5bf069bbc08f Mon Sep 17 00:00:00 2001 From: Karel Fajkus Date: Tue, 23 Feb 2021 14:44:00 +0100 Subject: [PATCH] Hikari autocommit (#466) * added autoCommit flag to hikari config * changed default value to false Co-authored-by: Karel Fajkus --- .../main/scala/com/avast/sst/doobie/DoobieHikariConfig.scala | 3 ++- .../main/scala/com/avast/sst/doobie/DoobieHikariModule.scala | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doobie-hikari/src/main/scala/com/avast/sst/doobie/DoobieHikariConfig.scala b/doobie-hikari/src/main/scala/com/avast/sst/doobie/DoobieHikariConfig.scala index f592638cd..f1b30f55a 100644 --- a/doobie-hikari/src/main/scala/com/avast/sst/doobie/DoobieHikariConfig.scala +++ b/doobie-hikari/src/main/scala/com/avast/sst/doobie/DoobieHikariConfig.scala @@ -24,5 +24,6 @@ final case class DoobieHikariConfig( registerMBeans: Boolean = false, validationTimeout: Option[FiniteDuration] = None, transactionIsolation: Option[TransactionIsolation] = None, - dataSourceProperties: Map[String, String] = Map.empty + dataSourceProperties: Map[String, String] = Map.empty, + autoCommit: Boolean = false ) diff --git a/doobie-hikari/src/main/scala/com/avast/sst/doobie/DoobieHikariModule.scala b/doobie-hikari/src/main/scala/com/avast/sst/doobie/DoobieHikariModule.scala index d8cce1a3e..20707beec 100644 --- a/doobie-hikari/src/main/scala/com/avast/sst/doobie/DoobieHikariModule.scala +++ b/doobie-hikari/src/main/scala/com/avast/sst/doobie/DoobieHikariModule.scala @@ -59,6 +59,7 @@ object DoobieHikariModule { c.setAllowPoolSuspension(config.allowPoolSuspension) c.setIsolateInternalQueries(config.isolateInternalQueries) c.setRegisterMbeans(config.registerMBeans) + c.setAutoCommit(config.autoCommit) val dataSourceProperties = new Properties() config.dataSourceProperties.foreach { case (k, v) => dataSourceProperties.put(k, v) } c.setDataSourceProperties(dataSourceProperties)