From 9c64807d3af68465473aec442bd0d435c0032c3c Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 5 Apr 2019 10:42:41 +0200 Subject: [PATCH] Upgraded Hibernate from 5.2.4.Final to 5.2.18.Final --- pom.xml | 2 +- src/it/update/update.sql | 4 +-- .../plugins/hibernate/AbstractSchemaMojo.java | 33 ++++++++++++++----- .../java/de/juplo/test/FileComparator.java | 10 ++++++ 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index ec837c19..8a61e22f 100644 --- a/pom.xml +++ b/pom.xml @@ -129,7 +129,7 @@ UTF-8 - 5.2.4.Final + 5.2.18.Final 5.3.1.Final 3.0.0 3.3.3 diff --git a/src/it/update/update.sql b/src/it/update/update.sql index 0c9457ca..d739136f 100644 --- a/src/it/update/update.sql +++ b/src/it/update/update.sql @@ -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; diff --git a/src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java b/src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java index 41c55ded..72ec9d4d 100644 --- a/src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java @@ -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 settings = + Collections.singletonMap( + AvailableSettings.CLASSLOADERS, + Collections.singletonList(classLoader) + ); + // Find all available persistent unit descriptors + List descriptors = + PersistenceXmlParser.locatePersistenceUnits(settings); + // Find all persistent units in the located descriptors Map units = - parser.doResolve(properties); + new HashMap(); + 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) { diff --git a/src/test/java/de/juplo/test/FileComparator.java b/src/test/java/de/juplo/test/FileComparator.java index beb25641..9229fc89 100644 --- a/src/test/java/de/juplo/test/FileComparator.java +++ b/src/test/java/de/juplo/test/FileComparator.java @@ -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!"); -- 2.20.1