Updated documentation
[hibernate4-maven-plugin] / src / site / xhtml / configuration.xhtml
index 8360b8f..712bdfb 100644 (file)
@@ -4,13 +4,14 @@
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>
-  <h2>Configuration through a hibernate.properties-File</h2>
+  <h2>Configuration Through A Configuration-File</h2>
   <p>
   The most simple way to configure the plugin is, to put all the
-  hibernate-configuration in a <strong>hibernate.properties</strong>-file on your
-  classpath. Put the file in the <code>resources</code>-folder. Maven will put
-  it in the <code>class</code>-folder of your webapp, where it will be picked up
-  by this plugin as well as by Hibernate 4.
+  hibernate-configuration in a <strong>hibernate.properties</strong>- or
+  a <strong>hibernate.cfg.xml</strong>-file on your classpath or in the
+  <strong>persistence.xml</strong>-file of your JPA-configuration, just
+  like you would do, if you are not using the
+  <code>hibernate-maven-plugin</code>.
   </p>
   <p>
   Doing so, the only additionally configuration needed, to activat the plugin
   <pre class="prettyprint linenums lang-html">
 &lt;plugin&gt;
   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
-  &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
+  &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;${project.version}&lt;/version&gt;
   &lt;executions&gt;
     &lt;execution&gt;
       &lt;goals&gt;
-        &lt;goal&gt;export&lt;/goal&gt;
+        &lt;goal&gt;create&lt;/goal&gt;
       &lt;/goals&gt;
     &lt;/execution&gt;
   &lt;/executions&gt;
 &lt;/plugin&gt;</pre>
   <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.
+  This would create the configured database.
+  If you want it to be droped beforehand, you have to add the goal
+  <code>drop</code>:
+  </p>
+  <pre class="prettyprint linenums lang-html">
+&lt;plugin&gt;
+  &lt;groupId&gt;de.juplo&lt;/groupId&gt;
+  &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
+  &lt;version&gt;${project.version}&lt;/version&gt;
+  &lt;executions&gt;
+    &lt;execution&gt;
+      &lt;goals&gt;
+        &lt;goal&gt;drop&lt;/goal&gt;
+        &lt;goal&gt;create&lt;/goal&gt;
+      &lt;/goals&gt;
+    &lt;/execution&gt;
+  &lt;/executions&gt;
+&lt;/plugin&gt;</pre>
+  <p>
+  A correspondin goal for the command <code>update</code> is missing in this
+  version, but we are planning to implement it in near feature.
+  </p>
+  <p>
+  In order to let this configuration work, your configuration file must
+  contain a complete valid configuration for the database, that you want
+  to use.
+  A simple example <code>hibernate.properties</code>-file may look like this:
+  </p>
+  <pre class="prettyprint linenums lang-properties">
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.url=jdbc:h2:file:./target/db
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.connection.username=sa
+hibernate.connection.password=</pre>
+  <p>
+  But be aware, that using this configuration-approach 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.
   Because of that,
   <strong>
     you should never fire up this configuration on your production
   <pre class="prettyprint linenums lang-html">
 &lt;plugin&gt;
   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
-  &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
+  &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;${project.version}&lt;/version&gt;
   &lt;executions&gt;
     &lt;execution&gt;
       &lt;goals&gt;
-        &lt;goal&gt;export&lt;/goal&gt;
+        &lt;goal&gt;drop&lt;/goal&gt;
+        &lt;goal&gt;create&lt;/goal&gt;
       &lt;/goals&gt;
     &lt;/execution&gt;
   &lt;/executions&gt;
   <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>).
+  (for a full list see the <a href="./create-mojo.html">Documentation of the goal create</a>).
   These are named after the
   <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc">Hibernate JDBC Properties</a>:
   </p>
 
   &lt;plugin&gt;
     &lt;groupId&gt;de.juplo&lt;/groupId&gt;
-    &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
+    &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
     &lt;version&gt;${project.version}&lt;/version&gt;
     &lt;executions&gt;
       &lt;execution&gt;
         &lt;goals&gt;
-          &lt;goal&gt;export&lt;/goal&gt;
+          &lt;goal&gt;drop&lt;/goal&gt;
+          &lt;goal&gt;create&lt;/goal&gt;
         &lt;/goals&gt;
       &lt;/execution&gt;
     &lt;/executions&gt;
   &lt;/plugin&gt;
 
 &lt;plugins&gt;</pre>
+  <p>
+  This way, you can reuse the same properties to provide a
+  default-configurationthe, that is build into your application, and
+  overwrite the database-url, that is used during testing to prevent
+  accidential drops of your production database.
+  </p>
   <h2>Configuration through the plugin-configuration</h2>
   <p>
   A third way for configuring the plugin is the plugin-configuration.
   The relevant configuration-parameters are:
   </p>
   <ul>
-    <li><code>driverClassName</code></li>
-    <li><code>hibernateDialect</code></li>
+    <li><code>driver</code></li>
+    <li><code>dialect</code></li>
     <li><code>url</code></li>
     <li><code>username</code></li>
     <li><code>password</code></li>
   <pre class="prettyprint linenums lang-html">
 &lt;plugin&gt;
   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
-  &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
+  &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;${project.version}&lt;/version&gt;
   &lt;executions&gt;
     &lt;execution&gt;
       &lt;goals&gt;
-        &lt;goal&gt;export&lt;/goal&gt;
+        &lt;goal&gt;drop&lt;/goal&gt;
+        &lt;goal&gt;create&lt;/goal&gt;
       &lt;/goals&gt;
     &lt;/execution&gt;
   &lt;/executions&gt;
   &lt;configuration&gt;
-    &lt;driverClassName&gt;org.hsqldb.jdbcDriver&lt;/driverClassName&gt;
-    &lt;hibernateDialect&gt;org.hibernate.dialect.HSQLDialect&lt;/hibernateDialect&gt;
+    &lt;driver&gt;org.hsqldb.jdbcDriver&lt;/driver&gt;
+    &lt;dialect&gt;org.hibernate.dialect.HSQLDialect&lt;/dialect&gt;
     &lt;url&gt;&lt;![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]&gt;&lt;/url&gt;
     &lt;username&gt;sa&lt;/username&gt;
     &lt;password&gt;&lt;/password&gt;
   </p>
   <p>
   For more explanations, see the
-  <a href="./export-mojo.html">Documentation of the export-Mojo</a>.
+  <a href="./create-mojo.html">Documentation of the goal create</a>.
   </p>
   <h2 id="precedence">Configuration-Method-Precedence</h2>
   <p>
   </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: <code>mvn -X hibernate4:export</code>
+  maven with the <a href="./debugging.html">debug-output</a> enabled: <code>mvn -X hibernate:create</code>
   and be aware, that maven-properties can be overwitten on the command-line,
   in your <code>~/.m2/settings.xml</code> and in a profile.
   </p>
   <pre class="prettyprint linenums lang-html">
 &lt;plugin&gt;
   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
-  &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
+  &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;${project.version}&lt;/version&gt;
   &lt;executions&gt;
     &lt;execution&gt;
       &lt;goals&gt;
-        &lt;goal&gt;export&lt;/goal&gt;
+        &lt;goal&gt;drop&lt;/goal&gt;
+        &lt;goal&gt;create&lt;/goal&gt;
       &lt;/goals&gt;
     &lt;/execution&gt;
   &lt;/executions&gt;