Upgraded Hibernate from 5.2.4.Final to 5.2.18.Final
authorKai Moritz <kai@juplo.de>
Fri, 5 Apr 2019 08:42:41 +0000 (10:42 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 5 Apr 2019 08:42:41 +0000 (10:42 +0200)
pom.xml
src/it/update/update.sql
src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java
src/test/java/de/juplo/test/FileComparator.java

diff --git a/pom.xml b/pom.xml
index ec837c1..8a61e22 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     <!-- Zeichensatz -->
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <!-- Verwendete Versionen -->
-    <hibernate.version>5.2.4.Final</hibernate.version>
+    <hibernate.version>5.2.18.Final</hibernate.version>
     <hibernate-validator.version>5.3.1.Final</hibernate-validator.version>
     <el-api.version>3.0.0</el-api.version>
     <maven.version>3.3.3</maven.version>
index 0c9457c..d739136 100644 (file)
@@ -1,3 +1,3 @@
 
-    alter table EVENTS 
-        add column MY_NEW_EVENT_DATE_COLUMN timestamp;
+    alter table TEST.PUBLIC.EVENTS 
+       add column MY_NEW_EVENT_DATE_COLUMN timestamp;
index 41c55de..72ec9d4 100644 (file)
@@ -27,7 +27,6 @@ import java.util.regex.Pattern;
 import javax.persistence.Embeddable;
 import javax.persistence.Entity;
 import javax.persistence.MappedSuperclass;
-import javax.persistence.spi.PersistenceUnitTransactionType;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
@@ -496,7 +495,7 @@ public abstract class AbstractSchemaMojo extends AbstractMojo
 
       /** Loading and merging configuration from persistence-unit(s) */
       ParsedPersistenceXmlDescriptor unit =
-          loadPersistenceUnit(classLoaderService, properties);
+          loadPersistenceUnit(classLoader, properties);
       if (unit != null)
         properties.putAll(unit.getProperties());
 
@@ -1381,20 +1380,36 @@ public abstract class AbstractSchemaMojo extends AbstractMojo
   }
 
   private ParsedPersistenceXmlDescriptor loadPersistenceUnit(
-      ClassLoaderService classLoaderService,
+      ClassLoader classLoader,
       Properties properties
       )
       throws
         MojoFailureException
   {
-    PersistenceXmlParser parser =
-        new PersistenceXmlParser(
-            classLoaderService,
-            PersistenceUnitTransactionType.RESOURCE_LOCAL
-             );
+    Map<String, ? extends Object> settings =
+        Collections.singletonMap(
+            AvailableSettings.CLASSLOADERS,
+            Collections.singletonList(classLoader)
+            );
+    // Find all available persistent unit descriptors
+    List<ParsedPersistenceXmlDescriptor> descriptors =
+        PersistenceXmlParser.locatePersistenceUnits(settings);
 
+    // Find all persistent units in the located descriptors
     Map<String, ParsedPersistenceXmlDescriptor> units =
-        parser.doResolve(properties);
+        new HashMap<String, ParsedPersistenceXmlDescriptor>();
+    for (ParsedPersistenceXmlDescriptor descriptor : descriptors)
+    {
+      String unit = descriptor.getName();
+      if (units.containsKey(unit))
+        getLog().warn(
+            "Persistence unit " + unit +
+            " from " + descriptor.getPersistenceUnitRootUrl() +
+            " overwrites unit with the same name from " +
+            units.get(unit).getPersistenceUnitRootUrl()
+            );
+      units.put(unit, descriptor);
+    }
 
     if (persistenceUnit == null)
     {
index beb2564..9229fc8 100644 (file)
@@ -5,6 +5,7 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.util.regex.Pattern;
 
 
 public class FileComparator
@@ -36,6 +37,15 @@ public class FileComparator
     while ((expected = expectedReader.readLine()) != null)
     {
       found = foundReader.readLine();
+      if (found == null)
+      {
+        System.err.println("Found less content than expected!");
+        System.err.println("First missing line: " + expected);
+        return false;
+      }
+
+      expected = expected.trim();
+      found = found.trim();
       if (!expected.equals(found))
       {
         System.err.println("Mismatch!");