X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsite%2Fxhtml%2Fconfiguration.xhtml;h=e6e738da861e4deb0dd49c15394eb2cab5fdb2b7;hb=d42dc8bc0d20f97e64dacd7983486fe18af0c8df;hp=e3ce8bcfcee0da50aa942317d0fff8c849c7362c;hpb=856dd31c9b90708e841163c91261a865f9efd224;p=hibernate4-maven-plugin diff --git a/src/site/xhtml/configuration.xhtml b/src/site/xhtml/configuration.xhtml index e3ce8bcf..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,20 +21,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 +83,13 @@
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:
+ 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:
<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 +108,7 @@
+ Configuration through the plugin-configuration
-
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>
@@ -167,7 +213,7 @@
For more explanations, see the - Documentation of the export-Mojo. + Documentation of the goal create.
@@ -175,12 +221,14 @@
hibernate.properties
hibernate.cfg.xml
persistence.xml
If you are in doubt about where a configuration-value comes from, run
- maven with the debug-output enabled: 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.
<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>