--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ </head>
+ <body>
+ <h2>Annotated classes in dependencies are not found.</h2>
+ <p>
+ hibernate4-maven-plugin by default scans dependencies in the scope
+ <code>compile</code>. You can configure it to scan dependencies in other
+ scopes as well. But it scans only direct dependencies. Transitive
+ dependencies are not scanned for annotated classes. If some of your
+ annotated classes are hidden in a transitive dependency, you can simply
+ add that dependency explicitly.
+ </p>
+ <h2>hibernate4-maven-plugin always needs a database-connection</h2>
+ <p>
+ The default-configuration uses the EXPORT-target of the SchemaExport-Tool.
+ If you do not need to create a database with the evaluated schema, you can
+ use the NONE- or the SCRIPT-target.
+ This can be achieved with the command-line parameter
+ <code>-Dhibernate.export.target=SCRIPT</code> or with the following configuration:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<configuration>
+ <target>SCRIPT</target>
+</configuration></pre>
+ <p>
+ But even when no database is to be created, hibernate always needs to know
+ the dialect. Hence, the plugin will fail if this parameter is missing!
+ </p>
+ <h2>Dependency for driver-class XYZ is missing</h2>
+ <p>
+ One regular problem is the scope of the jdbc-driver-dependency.
+ It is very unlikely, that this dependency is needed at compile-time.
+ So a tidy maven-developer would usually scope it for <code>runtime</code>.
+ </p>
+ <p>
+ But this will break the execution of the <code>hibernate4-maven-plugin</code>.
+ Since it will not be able to see the needed dependency, it will fail with
+ an error-message like:
+ </p>
+ <pre class="prettyprint">
+[INFO] Gathered hibernate-configuration (turn on debugging for details):
+[INFO] hibernate.connection.username = sa
+[INFO] hibernate.connection.password =
+[INFO] hibernate.dialect = org.hibernate.dialect.HSQLDialect
+[INFO] hibernate.connection.url = jdbc:hsqldb:/home/kai/mmf/target/mmf;shutdown=true
+[INFO] hibernate.connection.driver_class = org.hsqldb.jdbcDriver
+[ERROR] Dependency for driver-class org.hsqldb.jdbcDriver is missing!
+[INFO] ------------------------------------------------------------------------
+[ERROR] BUILD ERROR
+[INFO] ------------------------------------------------------------------------
+[INFO] org.hsqldb.jdbcDriver
+[INFO] ------------------------------------------------------------------------
+[INFO] For more information, run Maven with the -e switch
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 2 seconds
+[INFO] Finished at: Thu Nov 29 11:31:14 CET 2012
+[INFO] Final Memory: 32M/342M
+[INFO] ------------------------------------------------------------------------</pre>
+ <p>
+ A quick workaround for this error would be, to delete the runtime-constraint
+ for the jdbc-driver-dependency.
+ </p>
+ <p>
+ A much cleaner way is, to (additionally) ad the dependency, to the
+ plugin-definition:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate4-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>export</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>2.2.8</version>
+ </dependency>
+ </dependencies>
+</plugin></pre>
+ <p>
+ This is also the best way, if you use a different jdbc-driver for
+ testing, than in production.
+ Because otherwise, this dependency will unnecessarily bloat the
+ runtime-dependencies of your project.
+ </p>
+ <h2 id="fails">DBUnit fails after execution of hibernate4 was skipped because nothing has changed</h2>
+ <p>
+ If hibernate4-maven-plugin skips its excecution, this may lead to errors in
+ other plugins.
+ For example, when importing sample-data in the automatically created database
+ with the help of the <a href="http://mojo.codehaus.org/dbunit-maven-plugin/">dbunit-plugin</a>,
+ the <code>CLEAN_INSERT</code>-operation may fail because of foreign-key-constraints,
+ if the database was not recreated, because the hibernate4-maven-plugin has
+ skipped its excecution.
+ </p>
+ <p>
+ A quick fix to this problem is, to <a href="./force.html">force</a>
+ hibernate4-maven-plugin to export the schema every time it is running.
+ But to recreate the database on every testrun may noticeable slow down your
+ development cycle, if you have to wait for slow IO.
+ </p>
+ <p>
+ To circumvent this problem, hibernate4-maven-plugin signals a skipped
+ excecution by setting the maven property <code>$\{hibernate.export.skipped\}</code> to
+ <code>true</code>.
+ You can configure other plugins to react on this signal.
+ For example, the dbunit-plugin can be configured to skip its excecution, if
+ hibernate4-maven-plugin was skipped like this:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>dbunit-maven-plugin</artifactId>
+ <configuration>
+ <skip>${hibernate.export.skipped}</skip>
+ </configuration>
+</plugin></pre>
+ <h2>The database will not be recreated after a manual drop/clean</h2>
+ <p>
+ If one manually drops the database or removes the hsqldb-files, it will not
+ be recreated by the hibernate4-maven-plugin, because it cannot detect, that
+ the database needs to be recreated.
+ This happens, because the plugin will not recreate the database if neither
+ the configuration nor the annotated classes have changed, because an
+ unnecessary drop-create-cycle might take a long time. The plugin will
+ report that like this:
+ </p>
+ <pre class="prettyprint">
+[INFO] No modified annotated classes found and dialect unchanged.
+[INFO] Skipping schema generation!</pre>
+ <p>
+ If one always uses <code>mvn clean</code> for cleanup, this will not happen.
+ Otherwise the recreation must be <a href="./force.html">forced</a>:
+ </p>
+ <pre class="prettyprint">
+mvn hibernate4:export -Dhibernate.export.force=true</pre>
+ <h2>The hibernate4:export goal is not executed, when tests are skipped</h2>
+ <p>
+ The hibernate4-maven-plugin automatically skips its execution, when
+ <code>maven.test.skip</code> is set to <code>true</code>. If you need it to be always
+ executed, you can configure that explicitly like this:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+>plugin<
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate4-maven-plugin</artifactId>
+ ...
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+</plugin></pre>
+ <p>
+ Background-information for this design-decission can be found on the extra
+ page <a href="./skip.html">To skip or not to skip: that is the question</a>...
+ </p>
+ </body>
+</html>