--- /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>
+ <header><h1>Configuration Examples</h1></header>
+ <h2>Configuration Through A Configuration-File</h2>
+ <p>
+ The most simple way to configure the plugin is, to put all the
+ hibernate-configuration in a <strong>hibernate.properties</strong>- or
+ a <strong>hibernate.cfg.xml</strong>-file on your classpath or in the
+ <strong>persistence.xml</strong>-file of your JPA-configuration, just
+ like you would do, if you are not using the
+ <code>hibernate-maven-plugin</code>.
+ </p>
+ <p>
+ Doing so, the only additionally configuration needed, to activat the plugin
+ is the following entry in the <code>plugins</code>-section of your <code>pom.xml</code>:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+</plugin></pre>
+ <p>
+ This would create the configured database.
+ If you want it to be droped beforehand, you have to add the goal
+ <code>drop</code>:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>drop</goal>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+</plugin></pre>
+ <p>
+ A correspondin goal for the command <code>update</code> is missing in this
+ version, but we are planning to implement it in near feature.
+ </p>
+ <p>
+ In order to let this configuration work, your configuration file must
+ contain a complete valid configuration for the database, that you want
+ to use.
+ A simple example <code>hibernate.properties</code>-file may look like this:
+ </p>
+ <pre class="prettyprint linenums lang-properties">
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.url=jdbc:h2:file:./target/db
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.connection.username=sa
+hibernate.connection.password=</pre>
+ <p>
+ But be aware, that using this configuration-approach the database-url,
+ that is build in the application is the same that is used while testing,
+ where the database is droped and recreated by the plugin.
+ Because of that,
+ <strong>
+ you should never fire up this configuration on your production
+ system, or your database might be erased!
+ </strong>
+ </p>
+ <p>
+ A better approach is, to specify a different url for testing like in the
+ following snippet:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>drop</goal>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <url><![CDATA[jdbc:mysql://localhost/test-db]]></url>
+ </configuration>
+</plugin></pre>
+ <p>
+ Configuration properties, that are set in the <code>configuration</code>-section
+ of the plugin-configuration cannnot be overwritten elsewere (for details
+ see <a href="#precedence">Configuration-Method-Precedence</a>).
+ You never can overwrite them by accident when specifying a property on
+ the commandline or in your <code>settings.xml</code>.
+ </p>
+ <h2>Configuration through maven-properties</h2>
+ <p>
+ Alternatively, it is possible, to configure the plugin via maven-properties.
+ Each relevant configuration-option has a corresponding maven-property
+ (for a full list see the <a href="./create-mojo.html">Documentation of the goal create</a>).
+ These are named after the
+ <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc">Hibernate JDBC Properties</a>:
+ </p>
+ <ul>
+ <li><code>hibernate.connection.driver_class</code></li>
+ <li><code>hibernate.dialect</code></li>
+ <li><code>hibernate.connection.url</code></li>
+ <li><code>hibernate.connection.username</code></li>
+ <li><code>hibernate.connection.password</code></li>
+ </ul>
+ <p>
+ So, instead of writing the hibernate-configuration in the properties-file,
+ like above, you could put it in the <code>properties</code>-section of your
+ <code>pom.xml</code>.
+ </p>
+ <p>
+ Thogether with the plugin-definition from above, the following would
+ be a complete configuration (again, the database-url was overwritten in
+ the plugin-configuration, to be sure to have a separate database for
+ testing):
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<properties>
+ <hibernate.connection.driver_class>org.hsqldb.jdbcDriver</hibernate.connection.driver_class>
+ <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
+ <hibernate.connection.url><![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]></hibernate.connection.url>
+ <hibernate.connection.username>sa</hibernate.connection.username>
+ <hibernate.connection.password></hibernate.connection.password>
+</properties>
+
+...
+
+<plugins>
+
+ ...
+
+ <plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>drop</goal>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <url><![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]></url>
+ </configuration>
+ </plugin>
+
+<plugins></pre>
+ <p>
+ This way, you can reuse the same properties to provide a
+ default-configurationthe, that is build into your application, and
+ overwrite the database-url, that is used during testing to prevent
+ accidential drops of your production database.
+ </p>
+ <h2>Configuration through the plugin-configuration</h2>
+ <p>
+ A third way for configuring the plugin is the plugin-configuration.
+ The relevant configuration-parameters are:
+ </p>
+ <ul>
+ <li><code>driver</code></li>
+ <li><code>dialect</code></li>
+ <li><code>url</code></li>
+ <li><code>username</code></li>
+ <li><code>password</code></li>
+ </ul>
+ <p>
+ The equivalent of the configuration from the last section would look
+ like this:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>drop</goal>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <driver>org.hsqldb.jdbcDriver</driver>
+ <dialect>org.hibernate.dialect.HSQLDialect</dialect>
+ <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url>
+ <username>sa</username>
+ <password></password>
+ </configuration>
+</plugin></pre>
+ <p>
+ The parameter <strong>hibernateProperties</strong> (name of the hibernate-properties-file
+ to use, defaults to <strong>hibernate.properties</strong>) can only be configured through
+ this approach.
+ </p>
+ <p>
+ For more explanations, see the
+ <a href="./create-mojo.html">Documentation of the goal create</a>.
+ </p>
+ <h2 id="precedence">Configuration-Method-Precedence</h2>
+ <p>
+ The configuration is gathered in a fix order:
+ </p>
+ <ol>
+ <li><code>hibernate.properties</code></li>
+ <li><code>hibernate.cfg.xml</code></li>
+ <li><code>persistence.xml</code></li>
+ <li>maven-properties</li>
+ <li>plugin-configuration</li>
+ </ol>
+ <p>
+ If you are in doubt about where a configuration-value comes from, run
+ maven with the <a href="./debugging.html">debug-output</a> enabled: <code>mvn -X hibernate:create</code>
+ and be aware, that maven-properties can be overwitten on the command-line,
+ in your <code>~/.m2/settings.xml</code> and in a profile.
+ </p>
+ <p>
+ The plugin-configuration comes last and overwrites everything else.
+ That way, you can be sure, that a configuration-value, that is
+ specified in the plugin-configuration will never be overwritten by any
+ other configuration-method.
+ </p>
+ <p>
+ If you need to overwrite plugin-configuration-values with
+ maven-properties, you can use maven-properties in the plugin-configuration:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>drop</goal>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <password>${my-password-property}</password>
+ </configuration>
+</plugin></pre>
+ </body>
+</html>
--- /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>
+ <header><h1>Enable Debugging-Output</h1></header>
+ <p>
+ If you are new to <code>hibernate-maven-plugin</code>, in many cases, the
+ <a href="./configuration.html#precedence">Configuration-Method-Precedence</a>
+ may be the source of configuration errors.
+ To solve this problem, you should run maven with the debugging output
+ enabled.
+ For example, by executing:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+mvn -X compile hibernate:create</pre>
+ <p>
+ (The <code>compile</code> might be necessary, because <code>hibernate-maven-plugin</code>
+ has to scan the compiled classes for annotations!)
+ </p>
+ <p>
+ Unlike the majority of the maven-plugins, <code>hibernate-maven-plugin</code> was
+ designed to give a good many hints, when debugging is enabled.
+ Because, if you do not know, what went wrong, you can't fix it!
+ </p>
+ <p>
+ <strong>But be warned:</strong> <code>hibernate-maven-plugin</code> tends to be very chatty ;)
+ </p>
+ </body>
+</html>
--- /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>
+ <header><h1>Force Execution</h1></header>
+ <p>
+ The hibernate-maven-plugin computes MD5-sums for all found annotated
+ classes and stores them together with the generated schema.
+ If no classes were changed or added and the dialect wasn't changed too, it
+ automatically skips the configured SQL-generation — and more
+ important in this respect — the execution of the generated SQL,
+ to speed up the development cycle.
+ </p>
+ <p>
+ The plugin signals, that the execution was skipped by setting the maven
+ property <code>${hibernate.schema.skipped}</code> to <code>true</code>.
+ This may be helpful, because other plugins like
+ <a href="http://mojo.codehaus.org/dbunit-maven-plugin/">dbunit-plugin</a>
+ <a href="./pitfalls.html#fails">may fail</a>, when the execution is skipped.
+ </p>
+ <p>
+ If you need the hibernate-maven-plugin to <em>never skip execution automatically</em>,
+ you can force it to do so, if you set the parameter <code>force</code> to
+ <code>true</code>:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <force>true</force>
+ </configuration>
+</plugin></pre>
+ <p>
+ Or you may specify <code>-Dhibernate.schema.force=true</code> at the command line,
+ if you want to force hibernate-maven-plugin only once.
+ </p>
+ </body>
+</html>
--- /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>
+ <header><h1>${project.name}</h1></header>
+ <h2>${project.description}</h2>
+ <p>
+ The <strong>hibernate-maven-plugin</strong> is a plugin for generating a database-schema
+ from your Hibernate-Mappings and create or update your database
+ accordingly.
+ Its main usage is to automatically create and populate a test-database
+ for unit-tests in cooperation with the
+ <a href="http://mojo.codehaus.org/dbunit-maven-plugin">dbunit-maven-plugin</a>.
+ </p>
+ <p>
+ The plugin was designed with three main goals in mind:
+ </p>
+ <ul>
+ <li>It should be easy to use.</li>
+ <li>It should be maximal unlikely, to erase a producation-database by accident.</li>
+ <li>It should not slow down the development cycle.</li>
+ </ul>
+ <p>
+ To achieve the first goal, the convention-over-configuration paradigma
+ was applied and the plugin was stuffed with usefull logging-messages.
+ So, if in doubt, just turn on the <a href="./debugging.html">debugging output</a> with the <code>mvn -X ...</code>.
+ </p>
+ <p>
+ To achieve the second goal, the precedence in which the configuration
+ locations are consulted was layouted in a way that makes it possible, to
+ prevent overwrites of the wrong database by accident.
+ </p>
+ <p>
+ Last but not least, in order to not slow down the development cycle, the
+ hibernate-maven-plugin only executes the generated SQL, if the mapping
+ or the configuration has changed (or if you force it to do so).
+ </p>
+ <p>
+ For more information about the inspiration to write this tiny plugin,
+ <a href="/hibernate-maven-plugin-a-simple-plugin-for-generating-a-database-schema-from-hibernate-4-mapping-annotations/">read our blog-article about the hibernate-maven-plugin</a>.
+ </p>
+ <h2>Documentation</h2>
+ <ul>
+ <li>
+ See <a href="./configuration.html">Configuration Examples</a> for Usage-Explanations
+ and simple examples of how to use this plugin.
+ </li>
+ <li>
+ See <a href="./create-mojo.html">hibernate:create</a>,
+ See <a href="./update-mojo.html">hibernate:update</a> and
+ See <a href="./drop-mojo.html">hibernate:drop</a> and
+ See <a href="./help-mojo.html">hibernate:help</a> and
+ <a href="./plugin-info.html">Plugin Documentation</a> for the full
+ autogenerated documentation. These are mostly configuration-options
+ from the Hibernate-Tooling, that does the work in the background.
+ </li>
+ </ul>
+ <h2>Releases</h2>
+ <ul>
+ <li><a href="${project.url}">current version</a></li>
+ <li>${project.version} (this version)</li>
+ <li><a href="/projects/hibernate-maven-plugin/2.1.1/index.html">2.1.1</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/2.1.0/index.html">2.1.0</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/2.0.0/index.html">2.0.0</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/1.1.1/index.html">1.1.1</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/1.1.0/index.html">1.1.0</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/1.0.5/index.html">1.0.5</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/1.0.4/index.html">1.0.4</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/1.0.3/index.html">1.0.3</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/1.0.2/index.html">1.0.2</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/1.0.1/index.html">1.0.1</a></li>
+ <li><a href="/projects/hibernate-maven-plugin/1.0/index.html">1.0</a></li>
+ </ul>
+ </body>
+</html>
--- /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>
+ <header><h1>Issue Tracking</h1></header>
+ <strong>There is no bug-tracking system set up for this project!</strong>
+ <p>
+ Please send your bug-reports, questions or feature-requests directly
+ to the developer.
+ </p>
+ </body>
+</html>
--- /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>
+ <header><h1>Mailing Lists</h1></header>
+ <strong>There are no mailinglists defined for this project!</strong>
+ <p>
+ Please send your bug-reports, questions or feature-requests directly
+ to the developer.
+ </p>
+ </body>
+</html>
--- /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>
+ <header><h1>Known Pitfalls (FAQ)</h1></header>
+ <h2>Annotated classes in dependencies are not found.</h2>
+ <p>
+ hibernate-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>hibernate-maven-plugin always needs a database-connection</h2>
+ <p>
+ The default-configuration executes the created SQL.
+ Therefore, it needs a valid database-connection and fails, if none is
+ available.
+ If you do not need the generated SQL to be executed automatically,
+ you can set the property <code>hibernate.schema.execute</code> to
+ <code>false</code>.
+ This can be achieved with the command-line parameter
+ <code>-Dhibernate.schema.execute=false</code> or with the following
+ configuration:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<configuration>
+ <execute>false</execute>
+</configuration></pre>
+ <p>
+ But even when no database is to be created, hibernate always needs to know
+ the dialect. Hence, the plugin will still fail, if this parameter is also
+ 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>hibernate-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.H2Dialect
+[INFO] hibernate.connection.url = jdbc:h2:file:./db
+[INFO] hibernate.hbm2dll.create_namespaces = false
+[INFO] hibernate.connection.driver_class = org.h2.Driver
+[INFO] hibernate.format_sql = true
+[INFO] HHH000412: Hibernate Core {5.0.2.Final}
+[INFO] HHH000206: hibernate.properties not found
+[INFO] HHH000021: Bytecode provider name : javassist
+[INFO] Adding /home/kai/project/target/classes to the list of roots to scan...
+[INFO] Adding dependencies from scope compile to the list of roots to scan
+[INFO] Adding dependencies from scope org.hibernate:hibernate-core:jar:4.3.0.Final to the list of roots to scan
+[INFO] Adding annotated resource: de.juplo.tests.SimplestMavenHib4Test
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD FAILURE
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 1.760s
+[INFO] Finished at: Mon Mar 07 19:06:54 CET 2016
+[INFO] Final Memory: 11M/215M
+[INFO] ------------------------------------------------------------------------
+[ERROR] Failed to execute goal de.juplo:hibernate-maven-plugin:${project.version}:drop (default) on project hibernate4-properties-test: Could not open the JDBC-connection: Unable to load class [org.h2.Driver]: Could not load requested class : org.h2.Driver -> [Help 1]
+[ERROR]
+[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
+[ERROR] Re-run Maven using the -X switch to enable full debug logging.
+[ERROR]
+[ERROR] For more information about the errors and possible solutions, please read the following articles:
+[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException</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>hibernate-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>drop</goal>
+ <goal>create</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 hibernate was skipped because nothing has changed</h2>
+ <p>
+ If hibernate-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 hibernate-maven-plugin has
+ skipped its excecution.
+ </p>
+ <p>
+ A quick fix to this problem is, to <a href="./force.html">force</a>
+ hibernate-maven-plugin to generate and execute the SQL 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, hibernate-maven-plugin signals a skipped
+ excecution by setting the maven property <code>${hibernate.schema.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
+ hibernate-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.schema.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 hibernate-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 hibernate:create -Dhibernate.schema.force=true</pre>
+ <h2>The hibernate:create goal is not executed, when tests are skipped</h2>
+ <p>
+ The hibernate-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>hibernate-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>
+ <h2>I do not want my dependencies to be scanned for hibernate annotations</h2>
+ <p>
+ If you do not want your dependencies to be scanned for hibernate annotations,
+ you can pass <code>-Dhibernate.schema.scan.dependencies=none</code> to maven
+ or set <code>scanDependencies</code> to <code>none</code> in the configuration
+ of the plugin like this:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ ...
+ <configuration>
+ <scanDependencies>none</scanDependencies>
+ </configuration>
+</plugin></pre>
+ <h2>No annotated classes found</h2>
+ <p>
+ If you are working under Windows and get the error-message
+ <code>No annotated classes found in directory C:\projects\X Y Z\path-to-project\target\classes</code>,
+ but you are really sure, that there are annotated classes in that
+ directory, you are expiriencing a bug, in the scannotation-library, that
+ was closed in version 1.1.0 of the hibernate-maven-plugin.
+ </p>
+ <p>
+ <strong>
+ You should consider to upgrade to the latest version of the plugin.
+ </strong>
+ </p>
+ <h2>If two goals are specified, the second one is always skipped</h2>
+ <p>
+ If you specify two goals, for example <code>drop</code> and
+ <code>create</code>, each goal has to be specified in its own
+ <code>execution</code>, so that you can specify two different
+ output-files for the two goals.
+ Otherwise, both goals will use the same output-file and the goal, that
+ is run second, will always skip, becaus it will find, that the output
+ file already exists and conclude, that its work was already done in a
+ prior run.
+ </p>
+ <p>
+ Example configuration for two goals:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<executions>
+ <execution>
+ <id>Create Drop-Schema</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>drop</goal>
+ </goals>
+ <configuration>
+ <outputFile>db-schema/drop-schema.ddl</outputFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>Create Create-Schema</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <configuration>
+ <outputFile>db-schema/create-schema.ddl</outputFile>
+ </configuration>
+ </execution>
+</executions></pre>
+ </body>
+</html>
--- /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>
+ <header><h1>Skipping Execution</h1></header>
+ <p>
+ In most use-cases, the hibernate-maven-plugin is used to create a
+ test-database automatically. In this use-cases, it is very likely, that it
+ will result in mistakes/errors, if the goal is executed, when the tests
+ are skipped.
+ For example, one might manually overwrite the database-url with the url of
+ the production-database, in order to run other tests, like starting a
+ local webserver with the
+ <a href="http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin">jetty-maven-plugin</a>.
+ If the drop-goal would be executed in such a scenario, it might erase the
+ hole production-database, which is not very desireable.
+ </p>
+ <p>
+ Because of this, the configuration-parameter <code>skip</code> defaults to the value
+ of the proptery <code>maven.test.skip</code>. This way, the execution of the
+ hibernate-maven-plugin is skipped automatically, when the tests are
+ skipped. Think of it as a build-in security-belt.
+ </p>
+ <p>
+ If you do not like that, because you need the plugin to always,
+ even if the tests are skipped you can configure that explicitly,
+ by setting the configuration-parameter <code>skip</code> to false:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ ...
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+</plugin></pre>
+ <p>
+ Or, if you want the plugin to be executed by default and to be skipped
+ if you say so, you can bind the value of the configuration-parameter
+ <code>skip</code> to a custom property. For example:
+ </p>
+ <pre class="prettyprint linenums lang-html">
+<plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ ...
+ <configuration>
+ <skip>${foo.bar}</skip>
+ </configuration>
+</plugin></pre>
+ <p>
+ This way, the plugin would be skipped, if you set the property
+ <code>foo.bar</code> to <code>true</code>. For example, if you specify <code>-Dfoo.bar=true</code>
+ on the command-line.
+ </p>
+ </body>
+</html>
+++ /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>
- <header><h1>Configuration Examples</h1></header>
- <h2>Configuration Through A Configuration-File</h2>
- <p>
- The most simple way to configure the plugin is, to put all the
- hibernate-configuration in a <strong>hibernate.properties</strong>- or
- a <strong>hibernate.cfg.xml</strong>-file on your classpath or in the
- <strong>persistence.xml</strong>-file of your JPA-configuration, just
- like you would do, if you are not using the
- <code>hibernate-maven-plugin</code>.
- </p>
- <p>
- Doing so, the only additionally configuration needed, to activat the plugin
- is the following entry in the <code>plugins</code>-section of your <code>pom.xml</code>:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
-</plugin></pre>
- <p>
- This would create the configured database.
- If you want it to be droped beforehand, you have to add the goal
- <code>drop</code>:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>drop</goal>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
-</plugin></pre>
- <p>
- A correspondin goal for the command <code>update</code> is missing in this
- version, but we are planning to implement it in near feature.
- </p>
- <p>
- In order to let this configuration work, your configuration file must
- contain a complete valid configuration for the database, that you want
- to use.
- A simple example <code>hibernate.properties</code>-file may look like this:
- </p>
- <pre class="prettyprint linenums lang-properties">
-hibernate.dialect=org.hibernate.dialect.H2Dialect
-hibernate.connection.url=jdbc:h2:file:./target/db
-hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.username=sa
-hibernate.connection.password=</pre>
- <p>
- But be aware, that using this configuration-approach the database-url,
- that is build in the application is the same that is used while testing,
- where the database is droped and recreated by the plugin.
- Because of that,
- <strong>
- you should never fire up this configuration on your production
- system, or your database might be erased!
- </strong>
- </p>
- <p>
- A better approach is, to specify a different url for testing like in the
- following snippet:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>drop</goal>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <url><![CDATA[jdbc:mysql://localhost/test-db]]></url>
- </configuration>
-</plugin></pre>
- <p>
- Configuration properties, that are set in the <code>configuration</code>-section
- of the plugin-configuration cannnot be overwritten elsewere (for details
- see <a href="#precedence">Configuration-Method-Precedence</a>).
- You never can overwrite them by accident when specifying a property on
- the commandline or in your <code>settings.xml</code>.
- </p>
- <h2>Configuration through maven-properties</h2>
- <p>
- Alternatively, it is possible, to configure the plugin via maven-properties.
- Each relevant configuration-option has a corresponding maven-property
- (for a full list see the <a href="./create-mojo.html">Documentation of the goal create</a>).
- These are named after the
- <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc">Hibernate JDBC Properties</a>:
- </p>
- <ul>
- <li><code>hibernate.connection.driver_class</code></li>
- <li><code>hibernate.dialect</code></li>
- <li><code>hibernate.connection.url</code></li>
- <li><code>hibernate.connection.username</code></li>
- <li><code>hibernate.connection.password</code></li>
- </ul>
- <p>
- So, instead of writing the hibernate-configuration in the properties-file,
- like above, you could put it in the <code>properties</code>-section of your
- <code>pom.xml</code>.
- </p>
- <p>
- Thogether with the plugin-definition from above, the following would
- be a complete configuration (again, the database-url was overwritten in
- the plugin-configuration, to be sure to have a separate database for
- testing):
- </p>
- <pre class="prettyprint linenums lang-html">
-<properties>
- <hibernate.connection.driver_class>org.hsqldb.jdbcDriver</hibernate.connection.driver_class>
- <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
- <hibernate.connection.url><![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]></hibernate.connection.url>
- <hibernate.connection.username>sa</hibernate.connection.username>
- <hibernate.connection.password></hibernate.connection.password>
-</properties>
-
-...
-
-<plugins>
-
- ...
-
- <plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>drop</goal>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <url><![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]></url>
- </configuration>
- </plugin>
-
-<plugins></pre>
- <p>
- This way, you can reuse the same properties to provide a
- default-configurationthe, that is build into your application, and
- overwrite the database-url, that is used during testing to prevent
- accidential drops of your production database.
- </p>
- <h2>Configuration through the plugin-configuration</h2>
- <p>
- A third way for configuring the plugin is the plugin-configuration.
- The relevant configuration-parameters are:
- </p>
- <ul>
- <li><code>driver</code></li>
- <li><code>dialect</code></li>
- <li><code>url</code></li>
- <li><code>username</code></li>
- <li><code>password</code></li>
- </ul>
- <p>
- The equivalent of the configuration from the last section would look
- like this:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>drop</goal>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <driver>org.hsqldb.jdbcDriver</driver>
- <dialect>org.hibernate.dialect.HSQLDialect</dialect>
- <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url>
- <username>sa</username>
- <password></password>
- </configuration>
-</plugin></pre>
- <p>
- The parameter <strong>hibernateProperties</strong> (name of the hibernate-properties-file
- to use, defaults to <strong>hibernate.properties</strong>) can only be configured through
- this approach.
- </p>
- <p>
- For more explanations, see the
- <a href="./create-mojo.html">Documentation of the goal create</a>.
- </p>
- <h2 id="precedence">Configuration-Method-Precedence</h2>
- <p>
- The configuration is gathered in a fix order:
- </p>
- <ol>
- <li><code>hibernate.properties</code></li>
- <li><code>hibernate.cfg.xml</code></li>
- <li><code>persistence.xml</code></li>
- <li>maven-properties</li>
- <li>plugin-configuration</li>
- </ol>
- <p>
- If you are in doubt about where a configuration-value comes from, run
- maven with the <a href="./debugging.html">debug-output</a> enabled: <code>mvn -X hibernate:create</code>
- and be aware, that maven-properties can be overwitten on the command-line,
- in your <code>~/.m2/settings.xml</code> and in a profile.
- </p>
- <p>
- The plugin-configuration comes last and overwrites everything else.
- That way, you can be sure, that a configuration-value, that is
- specified in the plugin-configuration will never be overwritten by any
- other configuration-method.
- </p>
- <p>
- If you need to overwrite plugin-configuration-values with
- maven-properties, you can use maven-properties in the plugin-configuration:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>drop</goal>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <password>${my-password-property}</password>
- </configuration>
-</plugin></pre>
- </body>
-</html>
+++ /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>
- <header><h1>Enable Debugging-Output</h1></header>
- <p>
- If you are new to <code>hibernate-maven-plugin</code>, in many cases, the
- <a href="./configuration.html#precedence">Configuration-Method-Precedence</a>
- may be the source of configuration errors.
- To solve this problem, you should run maven with the debugging output
- enabled.
- For example, by executing:
- </p>
- <pre class="prettyprint linenums lang-html">
-mvn -X compile hibernate:create</pre>
- <p>
- (The <code>compile</code> might be necessary, because <code>hibernate-maven-plugin</code>
- has to scan the compiled classes for annotations!)
- </p>
- <p>
- Unlike the majority of the maven-plugins, <code>hibernate-maven-plugin</code> was
- designed to give a good many hints, when debugging is enabled.
- Because, if you do not know, what went wrong, you can't fix it!
- </p>
- <p>
- <strong>But be warned:</strong> <code>hibernate-maven-plugin</code> tends to be very chatty ;)
- </p>
- </body>
-</html>
+++ /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>
- <header><h1>Force Execution</h1></header>
- <p>
- The hibernate-maven-plugin computes MD5-sums for all found annotated
- classes and stores them together with the generated schema.
- If no classes were changed or added and the dialect wasn't changed too, it
- automatically skips the configured SQL-generation — and more
- important in this respect — the execution of the generated SQL,
- to speed up the development cycle.
- </p>
- <p>
- The plugin signals, that the execution was skipped by setting the maven
- property <code>${hibernate.schema.skipped}</code> to <code>true</code>.
- This may be helpful, because other plugins like
- <a href="http://mojo.codehaus.org/dbunit-maven-plugin/">dbunit-plugin</a>
- <a href="./pitfalls.html#fails">may fail</a>, when the execution is skipped.
- </p>
- <p>
- If you need the hibernate-maven-plugin to <em>never skip execution automatically</em>,
- you can force it to do so, if you set the parameter <code>force</code> to
- <code>true</code>:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- <version>${project.version}</version>
- <configuration>
- <force>true</force>
- </configuration>
-</plugin></pre>
- <p>
- Or you may specify <code>-Dhibernate.schema.force=true</code> at the command line,
- if you want to force hibernate-maven-plugin only once.
- </p>
- </body>
-</html>
+++ /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>
- <header><h1>${project.name}</h1></header>
- <h2>${project.description}</h2>
- <p>
- The <strong>hibernate-maven-plugin</strong> is a plugin for generating a database-schema
- from your Hibernate-Mappings and create or update your database
- accordingly.
- Its main usage is to automatically create and populate a test-database
- for unit-tests in cooperation with the
- <a href="http://mojo.codehaus.org/dbunit-maven-plugin">dbunit-maven-plugin</a>.
- </p>
- <p>
- The plugin was designed with three main goals in mind:
- </p>
- <ul>
- <li>It should be easy to use.</li>
- <li>It should be maximal unlikely, to erase a producation-database by accident.</li>
- <li>It should not slow down the development cycle.</li>
- </ul>
- <p>
- To achieve the first goal, the convention-over-configuration paradigma
- was applied and the plugin was stuffed with usefull logging-messages.
- So, if in doubt, just turn on the <a href="./debugging.html">debugging output</a> with the <code>mvn -X ...</code>.
- </p>
- <p>
- To achieve the second goal, the precedence in which the configuration
- locations are consulted was layouted in a way that makes it possible, to
- prevent overwrites of the wrong database by accident.
- </p>
- <p>
- Last but not least, in order to not slow down the development cycle, the
- hibernate-maven-plugin only executes the generated SQL, if the mapping
- or the configuration has changed (or if you force it to do so).
- </p>
- <p>
- For more information about the inspiration to write this tiny plugin,
- <a href="/hibernate-maven-plugin-a-simple-plugin-for-generating-a-database-schema-from-hibernate-4-mapping-annotations/">read our blog-article about the hibernate-maven-plugin</a>.
- </p>
- <h2>Documentation</h2>
- <ul>
- <li>
- See <a href="./configuration.html">Configuration Examples</a> for Usage-Explanations
- and simple examples of how to use this plugin.
- </li>
- <li>
- See <a href="./create-mojo.html">hibernate:create</a>,
- See <a href="./update-mojo.html">hibernate:update</a> and
- See <a href="./drop-mojo.html">hibernate:drop</a> and
- See <a href="./help-mojo.html">hibernate:help</a> and
- <a href="./plugin-info.html">Plugin Documentation</a> for the full
- autogenerated documentation. These are mostly configuration-options
- from the Hibernate-Tooling, that does the work in the background.
- </li>
- </ul>
- <h2>Releases</h2>
- <ul>
- <li><a href="${project.url}">current version</a></li>
- <li>${project.version} (this version)</li>
- <li><a href="/projects/hibernate-maven-plugin/2.1.1/index.html">2.1.1</a></li>
- <li><a href="/projects/hibernate-maven-plugin/2.1.0/index.html">2.1.0</a></li>
- <li><a href="/projects/hibernate-maven-plugin/2.0.0/index.html">2.0.0</a></li>
- <li><a href="/projects/hibernate-maven-plugin/1.1.1/index.html">1.1.1</a></li>
- <li><a href="/projects/hibernate-maven-plugin/1.1.0/index.html">1.1.0</a></li>
- <li><a href="/projects/hibernate-maven-plugin/1.0.5/index.html">1.0.5</a></li>
- <li><a href="/projects/hibernate-maven-plugin/1.0.4/index.html">1.0.4</a></li>
- <li><a href="/projects/hibernate-maven-plugin/1.0.3/index.html">1.0.3</a></li>
- <li><a href="/projects/hibernate-maven-plugin/1.0.2/index.html">1.0.2</a></li>
- <li><a href="/projects/hibernate-maven-plugin/1.0.1/index.html">1.0.1</a></li>
- <li><a href="/projects/hibernate-maven-plugin/1.0/index.html">1.0</a></li>
- </ul>
- </body>
-</html>
+++ /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>
- <header><h1>Issue Tracking</h1></header>
- <strong>There is no bug-tracking system set up for this project!</strong>
- <p>
- Please send your bug-reports, questions or feature-requests directly
- to the developer.
- </p>
- </body>
-</html>
+++ /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>
- <header><h1>Mailing Lists</h1></header>
- <strong>There are no mailinglists defined for this project!</strong>
- <p>
- Please send your bug-reports, questions or feature-requests directly
- to the developer.
- </p>
- </body>
-</html>
+++ /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>
- <header><h1>Known Pitfalls (FAQ)</h1></header>
- <h2>Annotated classes in dependencies are not found.</h2>
- <p>
- hibernate-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>hibernate-maven-plugin always needs a database-connection</h2>
- <p>
- The default-configuration executes the created SQL.
- Therefore, it needs a valid database-connection and fails, if none is
- available.
- If you do not need the generated SQL to be executed automatically,
- you can set the property <code>hibernate.schema.execute</code> to
- <code>false</code>.
- This can be achieved with the command-line parameter
- <code>-Dhibernate.schema.execute=false</code> or with the following
- configuration:
- </p>
- <pre class="prettyprint linenums lang-html">
-<configuration>
- <execute>false</execute>
-</configuration></pre>
- <p>
- But even when no database is to be created, hibernate always needs to know
- the dialect. Hence, the plugin will still fail, if this parameter is also
- 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>hibernate-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.H2Dialect
-[INFO] hibernate.connection.url = jdbc:h2:file:./db
-[INFO] hibernate.hbm2dll.create_namespaces = false
-[INFO] hibernate.connection.driver_class = org.h2.Driver
-[INFO] hibernate.format_sql = true
-[INFO] HHH000412: Hibernate Core {5.0.2.Final}
-[INFO] HHH000206: hibernate.properties not found
-[INFO] HHH000021: Bytecode provider name : javassist
-[INFO] Adding /home/kai/project/target/classes to the list of roots to scan...
-[INFO] Adding dependencies from scope compile to the list of roots to scan
-[INFO] Adding dependencies from scope org.hibernate:hibernate-core:jar:4.3.0.Final to the list of roots to scan
-[INFO] Adding annotated resource: de.juplo.tests.SimplestMavenHib4Test
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD FAILURE
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 1.760s
-[INFO] Finished at: Mon Mar 07 19:06:54 CET 2016
-[INFO] Final Memory: 11M/215M
-[INFO] ------------------------------------------------------------------------
-[ERROR] Failed to execute goal de.juplo:hibernate-maven-plugin:${project.version}:drop (default) on project hibernate4-properties-test: Could not open the JDBC-connection: Unable to load class [org.h2.Driver]: Could not load requested class : org.h2.Driver -> [Help 1]
-[ERROR]
-[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
-[ERROR] Re-run Maven using the -X switch to enable full debug logging.
-[ERROR]
-[ERROR] For more information about the errors and possible solutions, please read the following articles:
-[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException</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>hibernate-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>drop</goal>
- <goal>create</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 hibernate was skipped because nothing has changed</h2>
- <p>
- If hibernate-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 hibernate-maven-plugin has
- skipped its excecution.
- </p>
- <p>
- A quick fix to this problem is, to <a href="./force.html">force</a>
- hibernate-maven-plugin to generate and execute the SQL 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, hibernate-maven-plugin signals a skipped
- excecution by setting the maven property <code>${hibernate.schema.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
- hibernate-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.schema.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 hibernate-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 hibernate:create -Dhibernate.schema.force=true</pre>
- <h2>The hibernate:create goal is not executed, when tests are skipped</h2>
- <p>
- The hibernate-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>hibernate-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>
- <h2>I do not want my dependencies to be scanned for hibernate annotations</h2>
- <p>
- If you do not want your dependencies to be scanned for hibernate annotations,
- you can pass <code>-Dhibernate.schema.scan.dependencies=none</code> to maven
- or set <code>scanDependencies</code> to <code>none</code> in the configuration
- of the plugin like this:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- ...
- <configuration>
- <scanDependencies>none</scanDependencies>
- </configuration>
-</plugin></pre>
- <h2>No annotated classes found</h2>
- <p>
- If you are working under Windows and get the error-message
- <code>No annotated classes found in directory C:\projects\X Y Z\path-to-project\target\classes</code>,
- but you are really sure, that there are annotated classes in that
- directory, you are expiriencing a bug, in the scannotation-library, that
- was closed in version 1.1.0 of the hibernate-maven-plugin.
- </p>
- <p>
- <strong>
- You should consider to upgrade to the latest version of the plugin.
- </strong>
- </p>
- <h2>If two goals are specified, the second one is always skipped</h2>
- <p>
- If you specify two goals, for example <code>drop</code> and
- <code>create</code>, each goal has to be specified in its own
- <code>execution</code>, so that you can specify two different
- output-files for the two goals.
- Otherwise, both goals will use the same output-file and the goal, that
- is run second, will always skip, becaus it will find, that the output
- file already exists and conclude, that its work was already done in a
- prior run.
- </p>
- <p>
- Example configuration for two goals:
- </p>
- <pre class="prettyprint linenums lang-html">
-<executions>
- <execution>
- <id>Create Drop-Schema</id>
- <phase>test-compile</phase>
- <goals>
- <goal>drop</goal>
- </goals>
- <configuration>
- <outputFile>db-schema/drop-schema.ddl</outputFile>
- </configuration>
- </execution>
- <execution>
- <id>Create Create-Schema</id>
- <phase>test-compile</phase>
- <goals>
- <goal>create</goal>
- </goals>
- <configuration>
- <outputFile>db-schema/create-schema.ddl</outputFile>
- </configuration>
- </execution>
-</executions></pre>
- </body>
-</html>
+++ /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>
- <header><h1>Skipping Execution</h1></header>
- <p>
- In most use-cases, the hibernate-maven-plugin is used to create a
- test-database automatically. In this use-cases, it is very likely, that it
- will result in mistakes/errors, if the goal is executed, when the tests
- are skipped.
- For example, one might manually overwrite the database-url with the url of
- the production-database, in order to run other tests, like starting a
- local webserver with the
- <a href="http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin">jetty-maven-plugin</a>.
- If the drop-goal would be executed in such a scenario, it might erase the
- hole production-database, which is not very desireable.
- </p>
- <p>
- Because of this, the configuration-parameter <code>skip</code> defaults to the value
- of the proptery <code>maven.test.skip</code>. This way, the execution of the
- hibernate-maven-plugin is skipped automatically, when the tests are
- skipped. Think of it as a build-in security-belt.
- </p>
- <p>
- If you do not like that, because you need the plugin to always,
- even if the tests are skipped you can configure that explicitly,
- by setting the configuration-parameter <code>skip</code> to false:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- ...
- <configuration>
- <skip>false</skip>
- </configuration>
-</plugin></pre>
- <p>
- Or, if you want the plugin to be executed by default and to be skipped
- if you say so, you can bind the value of the configuration-parameter
- <code>skip</code> to a custom property. For example:
- </p>
- <pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- ...
- <configuration>
- <skip>${foo.bar}</skip>
- </configuration>
-</plugin></pre>
- <p>
- This way, the plugin would be skipped, if you set the property
- <code>foo.bar</code> to <code>true</code>. For example, if you specify <code>-Dfoo.bar=true</code>
- on the command-line.
- </p>
- </body>
-</html>