From 5002604d2f9024dd7119190915b6c62c75fbe1d6 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 13 Dec 2012 16:19:55 +0100 Subject: [PATCH] schema is now rebuild, when SQL-dialect changes --- .../juplo/plugins/hibernate4/Hbm2DdlMojo.java | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java index c9d5013a..d2077703 100644 --- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java @@ -325,14 +325,6 @@ public class Hbm2DdlMojo extends AbstractMojo if (classes.isEmpty()) throw new MojoFailureException("No annotated classes found in directory " + outputDirectory); - if (!modified) - { - getLog().info("No modified annotated classes found."); - getLog().info("Skipping schema generation!"); - project.getProperties().setProperty("hibernate4.skipped", "true"); - return; - } - getLog().debug("Detected classes with mapping-annotations:"); for (Class annotatedClass : classes) getLog().debug(" " + annotatedClass.getName()); @@ -440,6 +432,33 @@ public class Hbm2DdlMojo extends AbstractMojo properties.setProperty(DIALECT, hibernateDialect); } + /** The generated SQL varies with the dialect! */ + if (md5s.containsKey(DIALECT)) + { + String dialect = properties.getProperty(DIALECT); + if (md5s.get(DIALECT).equals(dialect)) + getLog().debug("SQL-dialect unchanged."); + else + { + getLog().debug("SQL-dialect changed: " + dialect); + modified = true; + md5s.put(DIALECT, dialect); + } + } + else + { + modified = true; + md5s.put(DIALECT, properties.getProperty(DIALECT)); + } + + if (!modified) + { + getLog().info("No modified annotated classes found and dialect unchanged."); + getLog().info("Skipping schema generation!"); + project.getProperties().setProperty("hibernate4.skipped", "true"); + return; + } + getLog().info("Gathered hibernate-configuration (turn on debugging for details):"); if (properties.isEmpty()) { -- 2.20.1