+++ /dev/null
-<!DOCTYPE html>
-<!-- Generated by Apache Maven Doxia Site Renderer 1.6 at 2016-03-09 -->
- <!-- Current: pitfalls.html -->
-<!-- Active: index.html -->
-<!-- Path: [index.html, pitfalls.html] -->
-<!-- Skiplist: [index.html, configuration.html, create-mojo.html, drop-mojo.html, debugging.html, skip.html, force.html, pitfalls.html] -->
-<html>
- <head>
- <title>juplo - Hibernate Maven Plugin - Known Pitfalls (FAQ)</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link rel="canonical" href="http://juplo.de/hibernate-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/prettify.js"></script>
- <!--[if lt IE 9]>
- <script src="/js/html5shiv.js"></script>
- <![endif]-->
- <!--[if IE 8]>
- <link rel="stylesheet" type="text/css" href="/css/ie8.css" />
- <![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 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><a name="Annotated_classes_in_dependencies_are_not_found."></a>Annotated classes in dependencies are not found.</h2>
-
-<p>
- hibernate-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><a name="hibernate-maven-plugin_always_needs_a_database-connection"></a>hibernate-maven-plugin always needs a database-connection</h2>
-
-<p>
- The default-configuration exports the created schema to the configured
- database.
- Therefore, it needs a valid database-connection and fails, if none is
- available.
- If you do not need to export the created schema to a database,
- you can set the property <tt>hibernate.schema.export</tt> to
- <tt>false</tt>.
- This can be achieved with the command-line parameter
- <tt>-Dhibernate.schema.export=false</tt> or with the following
- configuration:
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<configuration>
- <export>false</export>
-</configuration></pre></div>
-
-<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>
- </div>
-<div class="section">
-<h2><a name="Dependency_for_driver-class_XYZ_is_missing"></a>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 <tt>runtime</tt>.
- </p>
-
-<p>
- But this will break the execution of the <tt>hibernate-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.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:2.0.0: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></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>hibernate-maven-plugin</artifactId>
- <version>2.0.0</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></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 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 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 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 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, hibernate-maven-plugin signals a skipped
- excecution by setting the maven property <tt>${hibernate.schema.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
- hibernate-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.schema.skipped}</skip>
- </configuration>
-</plugin></pre></div>
- </div>
-<div class="section">
-<h2><a name="The_database_will_not_be_recreated_after_a_manual_dropclean"></a>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>
-
-<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 hibernate:create -Dhibernate.schema.force=true</pre></div>
- </div>
-<div class="section">
-<h2><a name="The_hibernate:create_goal_is_not_executed_when_tests_are_skipped"></a>The hibernate:create goal is not executed, when tests are skipped</h2>
-
-<p>
- The hibernate-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>hibernate-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>
-<div class="section">
-<h2><a name="I_do_not_want_my_dependencies_to_be_scanned_for_hibernate_annotations"></a>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 <tt>-Dhibernate.schema.scan.dependencies=none</tt> to maven
- or set <tt>scanDependencies</tt> to <tt>none</tt> in the configuration
- of the plugin like this:
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate-maven-plugin</artifactId>
- ...
- <configuration>
- <scanDependencies>none</scanDependencies>
- </configuration>
-</plugin></pre></div>
- </div>
-<div class="section">
-<h2><a name="No_annotated_classes_found"></a>No annotated classes found</h2>
-
-<p>
- If you are working under Windows and get the error-message
- <tt>No annotated classes found in directory C:\projects\X Y Z\path-to-project\target\classes</tt>,
- 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>
- <b>
- You should consider to upgrade to the latest version of the plugin.
- </b>
- </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 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="create-mojo.html" class="s" title="Goal: CREATE">Goal: CREATE</a>
- </li>
- <li class="s">
- <a href="drop-mojo.html" class="s" title="Goal: DROP">Goal: DROP</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> 2016
- </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>