Upgraded Hibernate hibernate-5.4.10
authorKai Moritz <kai@juplo.de>
Fri, 2 Jun 2017 08:38:32 +0000 (10:38 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 2 Jun 2017 09:15:48 +0000 (11:15 +0200)
 * hibernate-core 5.2.4.Final -> 5.2.10.Final
 * hibernate-validator 5.3.1.Final -> 5.4.1.Final

pom.xml
src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java

diff --git a/pom.xml b/pom.xml
index a652147..c69da30 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-validator.version>5.3.1.Final</hibernate-validator.version>
+    <hibernate.version>5.2.10.Final</hibernate.version>
+    <hibernate-validator.version>5.4.1.Final</hibernate-validator.version>
     <el-api.version>3.0.0</el-api.version>
     <maven.version>3.3.3</maven.version>
     <maven-plugin-log4j.version>1.0.1</maven-plugin-log4j.version>
index 0f143f5..edf8d12 100644 (file)
@@ -490,8 +490,7 @@ public abstract class AbstractSchemaMojo extends AbstractMojo
       LoadedConfig config = loadConfig(configLoader);
       if (config != null)
         properties.putAll(config.getConfigurationValues());
-      ParsedPersistenceXmlDescriptor unit =
-          loadPersistenceUnit(classLoaderService, properties);
+      ParsedPersistenceXmlDescriptor unit = loadPersistenceUnit(properties);
       if (unit != null)
         properties.putAll(unit.getProperties());
 
@@ -1346,53 +1345,51 @@ public abstract class AbstractSchemaMojo extends AbstractMojo
   }
 
   private ParsedPersistenceXmlDescriptor loadPersistenceUnit(
-      ClassLoaderService classLoaderService,
       Properties properties
       )
       throws
         MojoFailureException
   {
-    PersistenceXmlParser parser =
-        new PersistenceXmlParser(
-            classLoaderService,
-            PersistenceUnitTransactionType.RESOURCE_LOCAL
-             );
-
-    Map<String, ParsedPersistenceXmlDescriptor> units =
-        parser.doResolve(properties);
+    List<ParsedPersistenceXmlDescriptor> units =
+        PersistenceXmlParser.locatePersistenceUnits(properties);
 
     if (persistenceUnit == null)
     {
-      Iterator<String> names = units.keySet().iterator();
-      if (!names.hasNext())
+      if (units.isEmpty())
       {
         getLog().info("Found no META-INF/persistence.xml.");
         return null;
       }
 
-      String name = names.next();
-      if (!names.hasNext())
+      if (units.size() == 1)
       {
-          getLog().info("Using persistence-unit " + name);
-          return units.get(name);
+        ParsedPersistenceXmlDescriptor descriptor = units.get(0);
+        getLog().info("Using persistence-unit " + descriptor.getName());
+        return descriptor;
       }
 
       StringBuilder builder = new StringBuilder();
       builder.append("No name provided and multiple persistence units found: ");
-      builder.append(name);
-      while(names.hasNext())
+      Iterator<ParsedPersistenceXmlDescriptor> it = units.iterator();
+      while(it.hasNext())
       {
-        builder.append(", ");
-        builder.append(names.next());
+        builder.append(it.next().getName());
+        if (it.hasNext())
+          builder.append(", ");
       }
       builder.append('.');
       throw new MojoFailureException(builder.toString());
     }
 
-    if (units.containsKey(persistenceUnit))
+    Iterator<ParsedPersistenceXmlDescriptor> it = units.iterator();
+    while(it.hasNext())
     {
-      getLog().info("Using configured persistence-unit " + persistenceUnit);
-      return units.get(persistenceUnit);
+      ParsedPersistenceXmlDescriptor descriptor =  it.next();
+      if (descriptor.getName().equals(persistenceUnit))
+      {
+        getLog().info("Using configured persistence-unit " + persistenceUnit);
+        return descriptor;
+      }
     }
 
     throw new MojoFailureException("Could not find persistence-unit " + persistenceUnit);