Now using connections managed by JPA instead of using JNDI mocking.
[utils] / test / hibernate / src / main / java / org / wamblee / support / persistence / hibernate / HibernateJpaCustomizer.java
index 910ba8dd01da661e7ce84caeaf0706c93e90f2cc..71bbb18c10028fd4c50583c941836816e477f9c9 100644 (file)
@@ -38,12 +38,17 @@ public class HibernateJpaCustomizer implements JpaCustomizer {
     @Override
     public void customize(PersistenceUnitDescription aPersistenceUnit,
         Map<String, String> aJpaProperties) {
-        // Hibernate: Override transaction type and datasource
-        aJpaProperties.put("javax.persistence.transactionType",
-            "RESOURCE_LOCAL");
-        aJpaProperties.put("javax.persistence.jtaDataSource", null);
-        aJpaProperties.put("javax.persistence.nonJtaDataSource",
-            aPersistenceUnit.getJndiName());
+        
+        System.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "true");
+        
+        // Set non-JPA connection properties for older versions of hibernate
+        System.getProperties().remove("hibernate.connection.datasource");
+        if (System.getProperty("hibernate.connection.datasource") != null ) { 
+            throw new RuntimeException("ERROR");
+        }
+        System.setProperty("hibernate.connection.url", aJpaProperties.get("javax.persistence.jdbc.url"));
+        System.setProperty("hibernate.connection.username", aJpaProperties.get("javax.persistence.jdbc.user"));
+        System.setProperty("hibernate.connection.password", aJpaProperties.get("javax.persistence.jdbc.password"));
 
         // Hibernate schema generation
         aJpaProperties.put("hibernate.hbm2ddl.auto", "create");