+++ /dev/null
-<!DOCTYPE html>
-<!-- Generated by Apache Maven Doxia Site Renderer 1.4 at 2014-06-02 -->
- <!-- Current: pitfalls.html -->
-<!-- Active: index.html -->
-<!-- Path: [index.html, pitfalls.html] -->
-<!-- Skiplist: [index.html, configuration.html, export-mojo.html, debugging.html, skip.html, force.html, pitfalls.html] -->
-<html>
- <head>
- <title>juplo - Hibernate 4 Maven Plugin - Known Pitfalls (FAQ)</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link rel="canonical" href="http://juplo.de/hibernate4-maven-plugin/pitfalls.html"/>
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" type="text/css" href="/css/base.css" />
- <style type="text/css">
- @import '/css/screen.css' screen;
- </style>
- <script src="/js/base.js"></script>
- <!--[if IE 8]>
- <link rel="stylesheet" type="text/css" href="/css/ie8.css" />
- <script src="/js/ie8.js"></script>
- <![endif]-->
- <!--[if IE 7]>
- <script src="/js/ie7.js"></script>
- <![endif]-->
- <!--[if lt IE 7]>
- <script src="/js/ie6.js"></script>
- <![endif]-->
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- <body class="menu" onload="prettyPrint()">
- <div id="page" class="cf">
- <header id="header">
- <h1 id="logo"><a href="/" title="Home" class="l">juplo</a></h1>
- <span id="slogan"><strong>Java</strong> bits from nerds for nerds</span>
- <hr class="h" />
- </header>
- <div id="breadcrumb">
- <strong class="b title">You are here:</strong>
- <ol class="b">
- <li class="b"><a class="b" href="/">Home</a></li>
- <li class="b"><a class="b" href="/projects.html">Projects</a></li>
- <li class="b"><a class="b" href="./index.html">Hibernate 4 Maven Plugin</a></li>
- <li class="b"><strong class="b">Known Pitfalls (FAQ)</strong></li>
- </ol>
- <a class="hide" href="#navigation">Jump to navigation</a>
- <hr class="b" />
- </div>
- <main class="content cf">
- <article id="content" class="main">
- <header><h1>Known Pitfalls (FAQ)</h1></header>
-
-
-
-
-<div class="section">
-<h2>Annotated classes in dependencies are not found.<a name="Annotated_classes_in_dependencies_are_not_found."></a></h2>
-
-<p>
- hibernate4-maven-plugin by default scans dependencies in the scope
- <tt>compile</tt>. 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>
- </div>
-<div class="section">
-<h2>hibernate4-maven-plugin always needs a database-connection<a name="hibernate4-maven-plugin_always_needs_a_database-connection"></a></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
- <tt>-Dhibernate.export.target=SCRIPT</tt> or with the following configuration:
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<configuration>
- <target>SCRIPT</target>
-</configuration></pre></div>
-
-<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>
- </div>
-<div class="section">
-<h2>Dependency for driver-class XYZ is missing<a name="Dependency_for_driver-class_XYZ_is_missing"></a></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 <tt>runtime</tt>.
- </p>
-
-<p>
- But this will break the execution of the <tt>hibernate4-maven-plugin</tt>.
- Since it will not be able to see the needed dependency, it will fail with
- an error-message like:
- </p>
-
-<div>
-<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></div>
-
-<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>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate4-maven-plugin</artifactId>
- <version>1.0.4</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></div>
-
-<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>
- </div>
-<div class="section" id="fails">
-<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 class="externalLink" href="http://mojo.codehaus.org/dbunit-maven-plugin/">dbunit-plugin</a>,
- the <tt>CLEAN_INSERT</tt>-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 <tt>$\{hibernate.export.skipped\}</tt> to
- <tt>true</tt>.
- 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>
-
-<div>
-<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></div>
- </div>
-<div class="section">
-<h2>The database will not be recreated after a manual drop/clean<a name="The_database_will_not_be_recreated_after_a_manual_dropclean"></a></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>
-
-<div>
-<pre class="prettyprint">
-[INFO] No modified annotated classes found and dialect unchanged.
-[INFO] Skipping schema generation!</pre></div>
-
-<p>
- If one always uses <tt>mvn clean</tt> for cleanup, this will not happen.
- Otherwise the recreation must be <a href="./force.html">forced</a>:
- </p>
-
-<div>
-<pre class="prettyprint">
-mvn hibernate4:export -Dhibernate.export.force=true</pre></div>
- </div>
-<div class="section">
-<h2>The hibernate4:export goal is not executed, when tests are skipped<a name="The_hibernate4:export_goal_is_not_executed_when_tests_are_skipped"></a></h2>
-
-<p>
- The hibernate4-maven-plugin automatically skips its execution, when
- <tt>maven.test.skip</tt> is set to <tt>true</tt>. If you need it to be always
- executed, you can configure that explicitly like this:
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
->plugin<
- <groupId>de.juplo</groupId>
- <artifactId>hibernate4-maven-plugin</artifactId>
- ...
- <configuration>
- <skip>false</skip>
- </configuration>
-</plugin></pre></div>
-
-<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>
- </div>
-
- </article>
- <div class="marginal">
- <nav id="nav">
- <hr class="n" />
- <a id="navigation"></a>
- <a class="hide" href="#top" title="Show Content">Jump back to the top of the page</a>
- <h2 class="nav menu">Section-Menu</h2>
- <ul id="menu">
- <li class="m blog"><a href="/blog/" class="m">Blog</a></li>
- <li class="m projects"><a href="/projects.html" class="m selected">Projects</a></li>
- <li class="m about"><a href="/about.html" class="m">About</a></li>
- </ul>
- <h2 class="nav submenu">
- <span class="s">Submenu for section</span>
- <a class="s selected" href="/projects.html">Projects</a>
- </h2>
- <ul id="submenu" class="s">
- <li class="s sub">
- <a class="s selected" href="./index.html">Hibernate 4 Maven Plugin</a>
- <ul class="s active">
- <li class="s">
- <a href="configuration.html" class="s" title="Configuration Examples">Configuration Examples</a>
- </li>
- <li class="s">
- <a href="export-mojo.html" class="s" title="Parameter Documentation">Parameter Documentation</a>
- </li>
- <li class="s">
- <a href="debugging.html" class="s" title="Enable Debug-Output">Enable Debug-Output</a>
- </li>
- <li class="s">
- <a href="skip.html" class="s" title="Skipping Execution">Skipping Execution</a>
- </li>
- <li class="s">
- <a href="force.html" class="s" title="Force Exceution">Force Exceution</a>
- </li>
- <li class="s">
- <strong class="s">Known Pitfalls (FAQ)</strong>
- </li>
- <li class="s sub">
- <a href="project-info.html" class="s" title="Project Information">Project Information</a>
- </li>
- <li class="s sub">
- <a href="project-reports.html" class="s" title="Project Reports">Project Reports</a>
- </li>
- </ul>
- </li>
- </ul>
- <hr class="n" />
- </nav>
- <aside class="m">
- <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
- <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
- </a>
- </aside>
- </div>
- </main>
- <footer id="footer">
- <hr class="f" />
- <ul id="footerlinks">
- <li class="f" id="copyright">© <strong>mo</strong> 2014
- </li>
- <li class="f"><a class="f" href="/impressum.html">Impressum</a></li>
- <li class="f about"><a class="f" href="/about.html">About</a></li>
- </ul>
- </footer>
- </div>
- <script type="text/javascript"><!--//--><![CDATA[//><!--
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-571104-3']);
- _gaq.push(['_trackPageview']);
- (function() {
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })();
- //--><!]]>
- </script>
- </body>
-</html>