2 <!-- Generated by Apache Maven Doxia Site Renderer 1.4 at 2014-06-02 -->
3 <!-- Current: configuration.html -->
4 <!-- Active: index.html -->
5 <!-- Path: [index.html, configuration.html] -->
6 <!-- Skiplist: [index.html, configuration.html, export-mojo.html, debugging.html, skip.html, force.html, pitfalls.html] -->
9 <title>juplo - Hibernate 4 Maven Plugin - Configuration Examples</title>
10 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11 <link rel="canonical" href="http://juplo.de/hibernate4-maven-plugin/configuration.html"/>
12 <meta name="viewport" content="width=device-width, initial-scale=1" />
13 <link rel="stylesheet" type="text/css" href="/css/base.css" />
14 <style type="text/css">
15 @import '/css/screen.css' screen;
17 <script src="/js/base.js"></script>
19 <link rel="stylesheet" type="text/css" href="/css/ie8.css" />
20 <script src="/js/ie8.js"></script>
23 <script src="/js/ie7.js"></script>
26 <script src="/js/ie6.js"></script>
28 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
30 <body class="menu" onload="prettyPrint()">
31 <div id="page" class="cf">
33 <h1 id="logo"><a href="/" title="Home" class="l">juplo</a></h1>
34 <span id="slogan"><strong>Java</strong> bits from nerds for nerds</span>
38 <strong class="b title">You are here:</strong>
40 <li class="b"><a class="b" href="/">Home</a></li>
41 <li class="b"><a class="b" href="/projects.html">Projects</a></li>
42 <li class="b"><a class="b" href="./index.html">Hibernate 4 Maven Plugin</a></li>
43 <li class="b"><strong class="b">Configuration Examples</strong></li>
45 <a class="hide" href="#navigation">Jump to navigation</a>
48 <main class="content cf">
49 <article id="content" class="main">
50 <header><h1>Configuration Examples</h1></header>
56 <h2>Configuration through a hibernate.properties-File<a name="Configuration_through_a_hibernate.properties-File"></a></h2>
59 The most simple way to configure the plugin is, to put all the
60 hibernate-configuration in a <b>hibernate.properties</b>-file on your
61 classpath. Put the file in the <tt>resources</tt>-folder. Maven will put
62 it in the <tt>class</tt>-folder of your webapp, where it will be picked up
63 by this plugin as well as by Hibernate 4.
67 Doing so, the only additionally configuration needed, to activat the plugin
68 is the following entry in the <tt>plugins</tt>-section of your <tt>pom.xml</tt>:
72 <pre class="prettyprint linenums lang-html">
74 <groupId>de.juplo</groupId>
75 <artifactId>hibernate4-maven-plugin</artifactId>
76 <version>1.0.4</version>
80 <goal>export</goal>
84 </plugin></pre></div>
87 But be aware, that in this case the database-url, that is
88 build in the application is the same that is used while testing, where
89 the database is droped and recreated by the plugin.
92 you should never fire up this configuration on your production
93 system, or your database might be erased!
98 A better approach is, to specify a different url for testing like in the
103 <pre class="prettyprint linenums lang-html">
105 <groupId>de.juplo</groupId>
106 <artifactId>hibernate4-maven-plugin</artifactId>
107 <version>1.0.4</version>
111 <goal>export</goal>
115 <configuration>
116 <url><![CDATA[jdbc:mysql://localhost/test-db]]></url>
117 </configuration>
118 </plugin></pre></div>
121 Configuration properties, that are set in the <tt>configuration</tt>-section
122 of the plugin-configuration cannnot be overwritten elsewere (for details
123 see <a href="#precedence">Configuration-Method-Precedence</a>).
124 You never can overwrite them by accident when specifying a property on
125 the commandline or in your <tt>settings.xml</tt>.
128 <div class="section">
129 <h2>Configuration through maven-properties<a name="Configuration_through_maven-properties"></a></h2>
132 Alternatively, it is possible, to configure the plugin via maven-properties.
133 Each relevant configuration-option has a corresponding maven-property
134 (for a full list see the <a href="./export-mojo.html">Documentation of the export-Mojo</a>).
135 These are named after the
136 <a class="externalLink" href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc">Hibernate JDBC Properties</a>:
141 <li><tt>hibernate.connection.driver_class</tt></li>
143 <li><tt>hibernate.dialect</tt></li>
145 <li><tt>hibernate.connection.url</tt></li>
147 <li><tt>hibernate.connection.username</tt></li>
149 <li><tt>hibernate.connection.password</tt></li>
153 So, instead of writing the hibernate-configuration in the properties-file,
154 like above, you could put it in the <tt>properties</tt>-section of your
159 Thogether with the plugin-definition from above, the following would
160 be a complete configuration (again, the database-url was overwritten in
161 the plugin-configuration, to be sure to have a separate database for
166 <pre class="prettyprint linenums lang-html">
168 <hibernate.connection.driver_class>org.hsqldb.jdbcDriver</hibernate.connection.driver_class>
169 <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
170 <hibernate.connection.url><![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]></hibernate.connection.url>
171 <hibernate.connection.username>sa</hibernate.connection.username>
172 <hibernate.connection.password></hibernate.connection.password>
182 <groupId>de.juplo</groupId>
183 <artifactId>hibernate4-maven-plugin</artifactId>
184 <version>1.0.4</version>
188 <goal>export</goal>
192 <configuration>
193 <url><![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]></url>
194 </configuration>
197 <plugins></pre></div>
199 <div class="section">
200 <h2>Configuration through the plugin-configuration<a name="Configuration_through_the_plugin-configuration"></a></h2>
203 A third way for configuring the plugin is the plugin-configuration.
204 The relevant configuration-parameters are:
209 <li><tt>driverClassName</tt></li>
211 <li><tt>hibernateDialect</tt></li>
213 <li><tt>url</tt></li>
215 <li><tt>username</tt></li>
217 <li><tt>password</tt></li>
221 The equivalent of the configuration from the last section would look
226 <pre class="prettyprint linenums lang-html">
228 <groupId>de.juplo</groupId>
229 <artifactId>hibernate4-maven-plugin</artifactId>
230 <version>1.0.4</version>
234 <goal>export</goal>
238 <configuration>
239 <driverClassName>org.hsqldb.jdbcDriver</driverClassName>
240 <hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
241 <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url>
242 <username>sa</username>
243 <password></password>
244 </configuration>
245 </plugin></pre></div>
248 The parameter <b>hibernateProperties</b> (name of the hibernate-properties-file
249 to use, defaults to <b>hibernate.properties</b>) can only be configured through
254 For more explanations, see the
255 <a href="./export-mojo.html">Documentation of the export-Mojo</a>.
258 <div class="section" id="precedence">
259 <h2 id="precedence">Configuration-Method-Precedence</h2>
262 The configuration is gathered in a fix order:
265 <ol style="list-style-type: decimal">
267 <li><tt>hibernate.properties</tt></li>
269 <li>maven-properties</li>
271 <li>plugin-configuration</li>
275 If you are in doubt about where a configuration-value comes from, run
276 maven with the <a href="./debugging.html">debug-output</a> enabled: <tt>mvn -X hibernate4:export</tt>
277 and be aware, that maven-properties can be overwitten on the command-line,
278 in your <tt>~/.m2/settings.xml</tt> and in a profile.
282 The plugin-configuration comes last and overwrites everything else.
283 That way, you can be sure, that a configuration-value, that is
284 specified in the plugin-configuration will never be overwritten by any
285 other configuration-method.
289 If you need to overwrite plugin-configuration-values with
290 maven-properties, you can use maven-properties in the plugin-configuration:
294 <pre class="prettyprint linenums lang-html">
296 <groupId>de.juplo</groupId>
297 <artifactId>hibernate4-maven-plugin</artifactId>
298 <version>1.0.4</version>
302 <goal>export</goal>
306 <configuration>
307 <password>${my-password-property}</password>
308 </configuration>
309 </plugin></pre></div>
313 <div class="marginal">
316 <a id="navigation"></a>
317 <a class="hide" href="#top" title="Show Content">Jump back to the top of the page</a>
318 <h2 class="nav menu">Section-Menu</h2>
320 <li class="m blog"><a href="/blog/" class="m">Blog</a></li>
321 <li class="m projects"><a href="/projects.html" class="m selected">Projects</a></li>
322 <li class="m about"><a href="/about.html" class="m">About</a></li>
324 <h2 class="nav submenu">
325 <span class="s">Submenu for section</span>
326 <a class="s selected" href="/projects.html">Projects</a>
328 <ul id="submenu" class="s">
330 <a class="s selected" href="./index.html">Hibernate 4 Maven Plugin</a>
331 <ul class="s active">
333 <strong class="s">Configuration Examples</strong>
336 <a href="export-mojo.html" class="s" title="Parameter Documentation">Parameter Documentation</a>
339 <a href="debugging.html" class="s" title="Enable Debug-Output">Enable Debug-Output</a>
342 <a href="skip.html" class="s" title="Skipping Execution">Skipping Execution</a>
345 <a href="force.html" class="s" title="Force Exceution">Force Exceution</a>
348 <a href="pitfalls.html" class="s" title="Known Pitfalls (FAQ)">Known Pitfalls (FAQ)</a>
351 <a href="project-info.html" class="s" title="Project Information">Project Information</a>
354 <a href="project-reports.html" class="s" title="Project Reports">Project Reports</a>
362 <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
363 <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
370 <ul id="footerlinks">
371 <li class="f" id="copyright">© <strong>mo</strong> 2014
373 <li class="f"><a class="f" href="/impressum.html">Impressum</a></li>
374 <li class="f about"><a class="f" href="/about.html">About</a></li>
378 <script type="text/javascript"><!--//--><![CDATA[//><!--
379 var _gaq = _gaq || [];
380 _gaq.push(['_setAccount', 'UA-571104-3']);
381 _gaq.push(['_trackPageview']);
383 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
384 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
385 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);