Projekt-Dokumentation (Aktueller Stand von juplo.de) hinzugefĆ¼gt
[website] / dist / hibernate4-maven-plugin-1.0.1 / pitfalls.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
2 <!-- Generated by Apache Maven Doxia at Jan 15, 2013 -->\r
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r
4   <head>\r
5     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
6     <title>Hibernate 4 Maven Plugin - </title>\r
7     <style type="text/css" media="all">\r
8       @import url("./css/maven-base.css");\r
9       @import url("./css/maven-theme.css");\r
10       @import url("./css/site.css");\r
11     </style>\r
12     <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />\r
13     <meta name="Date-Revision-yyyymmdd" content="20130115" />\r
14     <meta http-equiv="Content-Language" content="en" />\r
15                                                     
16 <script type="text/javascript"><!--
17
18         var _gaq = _gaq || [];
19         _gaq.push(['_setAccount', 'UA-571104-3']);
20         _gaq.push(['_trackPageview']);
21
22         (function() {
23           var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
24           ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
25           var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
26         })();
27
28       //--></script>\r
29                       \r
30   </head>\r
31   <body class="composite">\r
32     <div id="banner">\r
33                     <div id="bannerLeft">\r
34                 Hibernate 4 Maven Plugin\r
35                 </div>\r
36                     <div class="clear">\r
37         <hr/>\r
38       </div>\r
39     </div>\r
40     <div id="breadcrumbs">\r
41             \r
42         \r
43                 <div class="xleft">\r
44         <span id="publishDate">Last Published: 2013-01-15</span>\r
45                   &nbsp;| <span id="projectVersion">Version: 1.0.1</span>\r
46                           |                           <a href="http://juplo.de" class="externalLink" title="juplo">juplo</a>\r
47                           </div>\r
48             <div class="xright">        \r
49         \r
50       </div>\r
51       <div class="clear">\r
52         <hr/>\r
53       </div>\r
54     </div>\r
55     <div id="leftColumn">\r
56       <div id="navcolumn">\r
57              \r
58         \r
59                                 <h5>Overview</h5>\r
60                   <ul>\r
61                   <li class="none">\r
62                           <a href="index.html" title="Introduction">Introduction</a>\r
63             </li>\r
64                   <li class="none">\r
65                           <a href="configuration.html" title="Configuration Examples">Configuration Examples</a>\r
66             </li>\r
67                   <li class="none">\r
68                           <a href="export-mojo.html" title="Parameter Documentation">Parameter Documentation</a>\r
69             </li>\r
70                   <li class="none">\r
71                           <a href="debugging.html" title="Enable Debug-Output">Enable Debug-Output</a>\r
72             </li>\r
73                   <li class="none">\r
74                           <a href="force.html" title="Force Exceution">Force Exceution</a>\r
75             </li>\r
76                   <li class="none">\r
77             <strong>Known Pitfalls</strong>\r
78           </li>\r
79           </ul>\r
80                        <h5>Project Documentation</h5>\r
81                   <ul>\r
82                                                                                                                                                                                                                                                         <li class="collapsed">\r
83                           <a href="project-info.html" title="Project Information">Project Information</a>\r
84                   </li>\r
85                                                                                                                                             <li class="collapsed">\r
86                           <a href="project-reports.html" title="Project Reports">Project Reports</a>\r
87                   </li>\r
88           </ul>\r
89                              <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">\r
90         <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />\r
91       </a>\r
92                    \r
93         \r
94             </div>\r
95     </div>\r
96     <div id="bodyColumn">\r
97       <div id="contentBox">\r
98         <div class="section"><h2>Known Pitfalls<a name="Known_Pitfalls"></a></h2><div class="section"><h3>Dependency for driver-class XYZ is missing<a name="Dependency_for_driver-class_XYZ_is_missing"></a></h3><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>[INFO] Gathered hibernate-configuration (turn on debugging for details):
99 [INFO]   hibernate.connection.username = sa
100 [INFO]   hibernate.connection.password = 
101 [INFO]   hibernate.dialect = org.hibernate.dialect.HSQLDialect
102 [INFO]   hibernate.connection.url = jdbc:hsqldb:/home/kai/mmf/target/mmf;shutdown=true
103 [INFO]   hibernate.connection.driver_class = org.hsqldb.jdbcDriver
104 [ERROR] Dependency for driver-class org.hsqldb.jdbcDriver is missing!
105 [INFO] ------------------------------------------------------------------------
106 [ERROR] BUILD ERROR
107 [INFO] ------------------------------------------------------------------------
108 [INFO] org.hsqldb.jdbcDriver
109 [INFO] ------------------------------------------------------------------------
110 [INFO] For more information, run Maven with the -e switch
111 [INFO] ------------------------------------------------------------------------
112 [INFO] Total time: 2 seconds
113 [INFO] Finished at: Thu Nov 29 11:31:14 CET 2012
114 [INFO] Final Memory: 32M/342M
115 [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>&lt;plugin&gt;
116   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
117   &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
118   &lt;version&gt;1.0.1&lt;/version&gt;
119   &lt;executions&gt;
120     &lt;execution&gt;
121       &lt;goals&gt;
122         &lt;goal&gt;export&lt;/goal&gt;
123       &lt;/goals&gt;
124     &lt;/execution&gt;
125   &lt;/executions&gt;
126   &lt;dependencies&gt;
127   &lt;dependency&gt;
128     &lt;groupId&gt;org.hsqldb&lt;/groupId&gt;
129     &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
130     &lt;version&gt;2.2.8&lt;/version&gt;
131   &lt;/dependency&gt;
132   &lt;/dependencies&gt;
133 &lt;/plugin&gt;</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"><h3>DBUnit <a name="fails">fails</a> after execution of hibernate4 was skipped because nothing has changed<a name="DBUnit_fails_after_execution_of_hibernate4_was_skipped_because_nothing_has_changed"></a></h3><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>$<a name="hibernate.export.skipped">hibernate.export.skipped</a></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>&lt;plugin&gt;
134   &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
135   &lt;artifactId&gt;dbunit-maven-plugin&lt;/artifactId&gt;
136   &lt;configuration&gt;
137     &lt;skip&gt;${hibernate.export.skipped}&lt;/skip&gt;
138   &lt;/configuration&gt;
139 &lt;/plugin&gt;</pre></div></div></div>\r
140       </div>\r
141     </div>\r
142     <div class="clear">\r
143       <hr/>\r
144     </div>\r
145     <div id="footer">\r
146       <div class="xright">Copyright &#169;                   2013.\r
147           All Rights Reserved.      \r
148         \r
149       </div>\r
150       <div class="clear">\r
151         <hr/>\r
152       </div>\r
153     </div>\r
154   </body>\r
155 </html>\r