WIP: Dummy-Seiten für Blog... RENAME: prefix/suffix
[website] / dist / hibernate4-maven-plugin-1.0.1 / configuration.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             <strong>Configuration Examples</strong>\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                           <a href="pitfalls.html" title="Known Pitfalls">Known Pitfalls</a>\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>Configuration Examples<a name="Configuration_Examples"></a></h2><div class="section"><h3>Configuration through a hibernate.properties-File<a name="Configuration_through_a_hibernate.properties-File"></a></h3><p>The most simple way to configure the plugin is, to put all the hibernate-configuration in a <b>hibernate.properties</b>-file on your classpath. Put the file in the <tt>resources</tt>-folder. Maven will put it in the <tt>class</tt>-folder of your webapp, where it will be picked up by this plugin as well as by Hibernate 4.</p><p>Doing so, the only additionally configuration needed, to activat the plugin is the following entry in the <tt>plugins</tt>-section of your <tt>pom.xml</tt>:</p><div><pre>&lt;plugin&gt;
99   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
100   &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
101   &lt;version&gt;1.0.1&lt;/version&gt;
102   &lt;executions&gt;
103     &lt;execution&gt;
104       &lt;goals&gt;
105         &lt;goal&gt;export&lt;/goal&gt;
106       &lt;/goals&gt;
107     &lt;/execution&gt;
108   &lt;/executions&gt;
109 &lt;/plugin&gt;</pre></div><p>But be aware, that in this case 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. <tt>So, you should never fire up this configuration on your production system, or your database might be erased!</tt></p><p>Hence, you should specify a different url for testing like in the following snippet:</p><div><pre>&lt;plugin&gt;
110   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
111   &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
112   &lt;version&gt;1.0.1&lt;/version&gt;
113   &lt;executions&gt;
114     &lt;execution&gt;
115       &lt;goals&gt;
116         &lt;goal&gt;export&lt;/goal&gt;
117       &lt;/goals&gt;
118     &lt;/execution&gt;
119   &lt;/executions&gt;
120   &lt;configuration&gt;
121     &lt;url&gt;&lt;![CDATA[jdbc:mysql://localhost/test-db]]&gt;&lt;/url&gt;
122   &lt;/configuration&gt;
123 &lt;/plugin&gt;</pre></div><p>Configuration properties, that are set in the <tt>configuration</tt>-section of the plugin-configuration cannnot be overwritten elsewere (for details see <a href="#Configuration-Method-Precedence">Configuration-Method-Precedence</a>). You never can overwrite them by accident when specifying a property on the commandline or in your <tt>settings.xml</tt>.</p></div><div class="section"><h3>Configuration through maven-properties<a name="Configuration_through_maven-properties"></a></h3><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="./export-mojo.html"> Documentation of the export-Mojo</a>). These are named after the <a class="externalLink" href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc"> Hibernate JDBC Properties</a>:</p><ul><li><tt>hibernate.connection.driver_class</tt></li><li><tt>hibernate.dialect</tt></li><li><tt>hibernate.connection.url</tt></li><li><tt>hibernate.connection.username</tt></li><li><tt>hibernate.connection.password</tt></li></ul><p>So, instead of writing the hibernate-configuration in the properties-file, like above, you could put it in the <tt>properties</tt>-section of your <tt>pom.xml</tt>.</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><div><pre>&lt;properties&gt;
124   &lt;hibernate.connection.driver_class&gt;org.hsqldb.jdbcDriver&lt;/hibernate.connection.driver_class&gt;
125   &lt;hibernate.dialect&gt;org.hibernate.dialect.HSQLDialect&lt;/hibernate.dialect&gt;
126   &lt;hibernate.connection.url&gt;&lt;![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]&gt;&lt;/hibernate.connection.url&gt;
127   &lt;hibernate.connection.username&gt;sa&lt;/hibernate.connection.username&gt;
128   &lt;hibernate.connection.password&gt;&lt;/hibernate.connection.password&gt;
129 &lt;/properties&gt;
130
131 ...
132
133 &lt;plugins&gt;
134
135   ...
136
137   &lt;plugin&gt;
138     &lt;groupId&gt;de.juplo&lt;/groupId&gt;
139     &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
140     &lt;version&gt;1.0.1&lt;/version&gt;
141     &lt;executions&gt;
142       &lt;execution&gt;
143         &lt;goals&gt;
144           &lt;goal&gt;export&lt;/goal&gt;
145         &lt;/goals&gt;
146       &lt;/execution&gt;
147     &lt;/executions&gt;
148     &lt;configuration&gt;
149       &lt;url&gt;&lt;![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]&gt;&lt;/url&gt;
150     &lt;/configuration&gt;
151   &lt;/plugin&gt;
152
153 &lt;plugins&gt;</pre></div></div><div class="section"><h3>Configuration through the plugin-configuration<a name="Configuration_through_the_plugin-configuration"></a></h3><p>A third way for configuring the plugin is the plugin-configuration. The relevant configuration-parameters are:</p><ul><li><tt>driverClassName</tt></li><li><tt>hibernateDialect</tt></li><li><tt>url</tt></li><li><tt>username</tt></li><li><tt>password</tt></li></ul><p>The equivalent of the configuration from the last section would look like this:</p><div><pre>&lt;plugin&gt;
154   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
155   &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
156   &lt;version&gt;1.0.1&lt;/version&gt;
157   &lt;executions&gt;
158     &lt;execution&gt;
159       &lt;goals&gt;
160         &lt;goal&gt;export&lt;/goal&gt;
161       &lt;/goals&gt;
162     &lt;/execution&gt;
163   &lt;/executions&gt;
164   &lt;configuration&gt;
165     &lt;driverClassName&gt;org.hsqldb.jdbcDriver&lt;/driverClassName&gt;
166     &lt;hibernateDialect&gt;org.hibernate.dialect.HSQLDialect&lt;/hibernateDialect&gt;
167     &lt;url&gt;&lt;![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]&gt;&lt;/url&gt;
168     &lt;username&gt;sa&lt;/username&gt;
169     &lt;password&gt;&lt;/password&gt;
170   &lt;/configuration&gt;
171 &lt;/plugin&gt;</pre></div><p>There are some seldom used parameters, that can only be configured throug this method:</p><ul><li><b>delimiter</b> the delimiter used in the generated sql-script</li><li><b>format</b> wether the generated sql-script is formatted, or not</li><li><b>hibernateProperties</b> name of the hibernate-properties-file</li><li><b>outputFile</b> name of the generated sql-script</li><li><b>target</b> create database or generate sql-script or both</li><li><b>type</b> create or drop the database or do both or nothing (just validate the annotation-configuration)</li></ul><p>For explanations, see the <a href="./export-mojo.html"> Documentation of the export-Mojo</a>.</p></div></div><div class="section"><h2><a name="Configuration-Method-Precedence">Configuration-Method-Precedence</a><a name="Configuration-Method-Precedence"></a></h2><p>The configuration is gathered in a fix order:</p><ol style="list-style-type: decimal"><li><tt>hibernate.properties</tt></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: <tt>mvn -X hibernate4:export</tt> and be aware, that maven-properties can be overwitten on the command-line, in your <tt>~/.m2/settings.xml</tt> 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 realy need to overwrite plugin-configuration-values with maven-properties, you can use maven-properties in the plugin-configuration:</p><div><pre>&lt;plugin&gt;
172   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
173   &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
174   &lt;version&gt;1.0.1&lt;/version&gt;
175   &lt;executions&gt;
176     &lt;execution&gt;
177       &lt;goals&gt;
178         &lt;goal&gt;export&lt;/goal&gt;
179       &lt;/goals&gt;
180     &lt;/execution&gt;
181   &lt;/executions&gt;
182   &lt;configuration&gt;
183     &lt;password&gt;${my-password-property}&lt;/password&gt;
184   &lt;/configuration&gt;
185 &lt;/plugin&gt;</pre></div></div>\r
186       </div>\r
187     </div>\r
188     <div class="clear">\r
189       <hr/>\r
190     </div>\r
191     <div id="footer">\r
192       <div class="xright">Copyright &#169;                   2013.\r
193           All Rights Reserved.      \r
194         \r
195       </div>\r
196       <div class="clear">\r
197         <hr/>\r
198       </div>\r
199     </div>\r
200   </body>\r
201 </html>\r