diff --git a/knockoutwhistweb/app/di/EntityManagerProvider.scala b/knockoutwhistweb/app/di/EntityManagerProvider.scala index 4a360ce..94b67d0 100644 --- a/knockoutwhistweb/app/di/EntityManagerProvider.scala +++ b/knockoutwhistweb/app/di/EntityManagerProvider.scala @@ -1,10 +1,9 @@ package di -import com.google.inject.Provider -import com.google.inject.Inject -import play.api.Configuration +import com.google.inject.{Inject, Provider} import jakarta.inject.Singleton import jakarta.persistence.{EntityManager, EntityManagerFactory, Persistence} +import play.api.Configuration @Singleton class EntityManagerProvider @Inject()(config: Configuration) extends Provider[EntityManager] { @@ -18,6 +17,14 @@ class EntityManagerProvider @Inject()(config: Configuration) extends Provider[En props.put("jakarta.persistence.jdbc.url", dbConfig.get[String]("url")) props.put("jakarta.persistence.jdbc.user", dbConfig.get[String]("username")) props.put("jakarta.persistence.jdbc.password", dbConfig.get[String]("password")) + + // Also pass HikariCP settings if present + dbConfig.getOptional[Configuration]("hikaricp").foreach { hikariConfig => + hikariConfig.keys.foreach { key => + val value = hikariConfig.underlying.getValue(key).unwrapped() + props.put(s"hibernate.hikari.$key", value) + } + } Persistence.createEntityManagerFactory("defaultPersistenceUnit", props) } diff --git a/knockoutwhistweb/conf/META-INF/persistence.xml b/knockoutwhistweb/conf/META-INF/persistence.xml index de56d10..5b25011 100644 --- a/knockoutwhistweb/conf/META-INF/persistence.xml +++ b/knockoutwhistweb/conf/META-INF/persistence.xml @@ -9,12 +9,6 @@ org.hibernate.jpa.HibernatePersistenceProvider - - - - - - diff --git a/knockoutwhistweb/conf/application.conf b/knockoutwhistweb/conf/application.conf index 6c8444e..6f59db2 100644 --- a/knockoutwhistweb/conf/application.conf +++ b/knockoutwhistweb/conf/application.conf @@ -2,6 +2,9 @@ play.filters.disabled += play.filters.csrf.CSRFFilter play.filters.disabled += play.filters.hosts.AllowedHostsFilter +# Disable default JPA and Hibernate modules to use custom EntityManagerProvider +play.modules.disabled += "play.db.jpa.JPAModule" + play.http.secret.key="QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241AB`R5W:1uDFN];Ik@n" play.http.secret.key=${?APPLICATION_SECRET}