X-Git-Url: https://juplo.de/gitweb/?p=hibernate4-maven-plugin;a=blobdiff_plain;f=src%2Fsite%2Fxhtml%2Fconfiguration.xhtml;h=712bdfb4c94336363ee6e92af05ef43cee48a31d;hp=8360b8f873bf6425609566cbea6d0987fd5233d6;hb=0611db682bc69b80d8567bf9316668a1b6161725;hpb=3541cf3742dd066b94365d351a3ca39a35e3d3c8 diff --git a/src/site/xhtml/configuration.xhtml b/src/site/xhtml/configuration.xhtml index 8360b8f8..712bdfb4 100644 --- a/src/site/xhtml/configuration.xhtml +++ b/src/site/xhtml/configuration.xhtml @@ -4,13 +4,14 @@ -

Configuration through a hibernate.properties-File

+

Configuration Through A Configuration-File

The most simple way to configure the plugin is, to put all the - hibernate-configuration in a hibernate.properties-file on your - classpath. Put the file in the resources-folder. Maven will put - it in the class-folder of your webapp, where it will be picked up - by this plugin as well as by Hibernate 4. + hibernate-configuration in a hibernate.properties- or + a hibernate.cfg.xml-file on your classpath or in the + persistence.xml-file of your JPA-configuration, just + like you would do, if you are not using the + hibernate-maven-plugin.

Doing so, the only additionally configuration needed, to activat the plugin @@ -19,20 +20,55 @@

 <plugin>
   <groupId>de.juplo</groupId>
-  <artifactId>hibernate4-maven-plugin</artifactId>
+  <artifactId>hibernate-maven-plugin</artifactId>
   <version>${project.version}</version>
   <executions>
     <execution>
       <goals>
-        <goal>export</goal>
+        <goal>create</goal>
       </goals>
     </execution>
   </executions>
 </plugin>

- 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 + drop: +

+
+<plugin>
+  <groupId>de.juplo</groupId>
+  <artifactId>hibernate-maven-plugin</artifactId>
+  <version>${project.version}</version>
+  <executions>
+    <execution>
+      <goals>
+        <goal>drop</goal>
+        <goal>create</goal>
+      </goals>
+    </execution>
+  </executions>
+</plugin>
+

+ A correspondin goal for the command update is missing in this + version, but we are planning to implement it in near feature. +

+

+ 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 hibernate.properties-file may look like this: +

+
+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=
+

+ 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, you should never fire up this configuration on your production @@ -46,12 +82,13 @@

 <plugin>
   <groupId>de.juplo</groupId>
-  <artifactId>hibernate4-maven-plugin</artifactId>
+  <artifactId>hibernate-maven-plugin</artifactId>
   <version>${project.version}</version>
   <executions>
     <execution>
       <goals>
-        <goal>export</goal>
+        <goal>drop</goal>
+        <goal>create</goal>
       </goals>
     </execution>
   </executions>
@@ -70,7 +107,7 @@
   

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 Documentation of the export-Mojo). + (for a full list see the Documentation of the goal create). These are named after the Hibernate JDBC Properties:

@@ -109,12 +146,13 @@ <plugin> <groupId>de.juplo</groupId> - <artifactId>hibernate4-maven-plugin</artifactId> + <artifactId>hibernate-maven-plugin</artifactId> <version>${project.version}</version> <executions> <execution> <goals> - <goal>export</goal> + <goal>drop</goal> + <goal>create</goal> </goals> </execution> </executions> @@ -124,14 +162,20 @@ </plugin> <plugins>
+

+ 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. +

Configuration through the plugin-configuration

A third way for configuring the plugin is the plugin-configuration. The relevant configuration-parameters are: