X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fsite%2Fxhtml%2Fconfiguration.xhtml;h=e6e738da861e4deb0dd49c15394eb2cab5fdb2b7;hb=64f720667c586f37a72ca1592fc5dbd4533dd557;hp=bfaf6fece527682180c85c6ba7ddfb65949dfca8;hpb=64900890db2575b7a28790c5e4d5f45083ee94b3;p=hibernate-maven-plugin diff --git a/src/site/xhtml/configuration.xhtml b/src/site/xhtml/configuration.xhtml index bfaf6fec..e6e738da 100644 --- a/src/site/xhtml/configuration.xhtml +++ b/src/site/xhtml/configuration.xhtml @@ -4,13 +4,15 @@
-
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,38 +21,75 @@
<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, - So, you should never fire up this configuration on your production + you should never fire up this configuration on your production system, or your database might be erased!
- Hence, you should specify a different url for testing like in the + A better approach is, to specify a different url for testing like in the following snippet:
<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> @@ -69,7 +108,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:
@@ -108,12 +147,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> @@ -123,14 +163,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. +
A third way for configuring the plugin is the plugin-configuration. The relevant configuration-parameters are:
driverClassName
hibernateDialect
driver
dialect
url
username
password
<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> <configuration> - <driverClassName>org.hsqldb.jdbcDriver</driverClassName> - <hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect> + <driver>org.hsqldb.jdbcDriver</driver> + <dialect>org.hibernate.dialect.HSQLDialect</dialect> <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url> <username>sa</username> <password></password> @@ -166,7 +213,7 @@For more explanations, see the - Documentation of the export-Mojo. + Documentation of the goal create.
Configuration-Method-Precedence
@@ -174,12 +221,14 @@
- +
hibernate.properties
- +
hibernate.cfg.xml
persistence.xml
- maven-properties
- plugin-configuration
If you are in doubt about where a configuration-value comes from, run - maven with the debug-output enabled:
@@ -190,18 +239,19 @@ other configuration-method.mvn -X hibernate4:export
+ maven with the debug-output enabled:mvn -X hibernate:create
and be aware, that maven-properties can be overwitten on the command-line, in your~/.m2/settings.xml
and in a profile.- If you realy need to overwrite plugin-configuration-values with + If you need to overwrite plugin-configuration-values with maven-properties, you can use maven-properties in the plugin-configuration:
<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>