diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaModelProvider.java b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaModelProvider.java index 629f7959c9..56b0a90b81 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaModelProvider.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaModelProvider.java @@ -1,5 +1,9 @@ package org.keycloak.models.jpa; +import java.util.Map; +import java.util.Properties; + +import org.jboss.resteasy.logging.Logger; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.ModelProvider; @@ -12,6 +16,8 @@ import javax.persistence.Persistence; */ public class JpaModelProvider implements ModelProvider { + private static final Logger logger = Logger.getLogger(JpaModelProvider.class); + @Override public String getId() { return "jpa"; @@ -19,8 +25,22 @@ public class JpaModelProvider implements ModelProvider { @Override public KeycloakSessionFactory createFactory() { - EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa-keycloak-identity-store"); + EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa-keycloak-identity-store", getHibernateProperties()); + logger.info("RDBMS connection url: " + emf.getProperties().get("hibernate.connection.url")); return new JpaKeycloakSessionFactory(emf); } + + // Allows to override some properties in persistence.xml by system properties + protected Properties getHibernateProperties() { + Properties result = new Properties(); + + for (Object property : System.getProperties().keySet()) { + if (property.toString().startsWith("hibernate.")) { + String propValue = System.getProperty(property.toString()); + result.put(property, propValue); + } + } + return result; + } } diff --git a/pom.xml b/pom.xml index 2f4bab5b35..21f7d6cb1d 100755 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,8 @@ 1.0.1.Final 4.0.1.Final 1.3.161 + 5.1.29 + 9.3-1100-jdbc41 1.6.1 5.1.25 1.6.1 @@ -544,5 +546,44 @@ distribution + + + + + + hibernate.connection.driver_class + com.mysql.jdbc.Driver + + + mysql + + + mysql + mysql-connector-java + ${mysql.version} + test + + + + + + + + + hibernate.connection.driver_class + org.postgresql.Driver + + + postgresql + + + org.postgresql + postgresql + postgresql.version + test + + + +