X-Git-Url: https://juplo.de/gitweb/?p=hibernate4-maven-plugin;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fplugins%2Fhibernate4%2FHbm2DdlMojo.java;h=f1b6a2cdb64a0dca74297b09430aacc7819af662;hp=3efa1852fe9cbc47cbe0350d0c435079f157aff2;hb=2a85cb05542795f9cd2eed448f212f92842a85e8;hpb=1e5cca792c49d60e20d7355eb97b13d591d80af6 diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java index 3efa1852..f1b6a2cd 100644 --- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java @@ -541,8 +541,11 @@ public class Hbm2DdlMojo extends AbstractMojo // Clear unused system-properties config.setProperties(new Properties()); + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + StandardServiceRegistryImpl registry = null; MavenLogAppender.startPluginLog(this); + try { /** Try to read configuration from properties-file */ @@ -841,20 +844,6 @@ public class Hbm2DdlMojo extends AbstractMojo } - Iterator it = config.getClassMappings(); - if (!it.hasNext()) - { - throw new MojoFailureException("No mapped classes found!"); - } - else - { - getLog().info("Mapped classes:"); - while (it.hasNext()) - { - getLog().debug(" " + it.next().getClassName()); - } - } - if (config.getProperty(DIALECT) == null) throw new MojoFailureException("hibernate-dialect must be set!"); @@ -897,7 +886,7 @@ public class Hbm2DdlMojo extends AbstractMojo Environment.verifyProperties(config.getProperties()); ConfigurationHelper.resolvePlaceHolders(config.getProperties()); - StandardServiceRegistryImpl registry = + registry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings(config.getProperties()) @@ -952,6 +941,9 @@ public class Hbm2DdlMojo extends AbstractMojo /** Restore the old class-loader (TODO: is this really necessary?) */ Thread.currentThread().setContextClassLoader(contextClassLoader); + + if (registry != null) + registry.destroy(); } /** Write md5-sums for annotated classes to file */