7 Configuration through a hibernate.properties-File
9 The most simple way to configure the plugin is, to put all the
10 hibernate-configuration in a <<hibernate.properties>>-file on your
11 classpath. Put the file in the <<<resources>>>-folder. Maven will put
12 it in the <<<class>>>-folder of your webapp, where it will be picked up
13 by this plugin as well as by Hibernate 4.
15 Doing so, the only additionally configuration needed, to activat the plugin
16 is the following entry in the <<<plugins>>>-section of your <<<pom.xml>>>:
20 <groupId>de.juplo</groupId>
21 <artifactId>hibernate4-maven-plugin</artifactId>
22 <version>${project.version}</version>
33 But be aware, that in this case the database-url, that is
34 build in the application is the same that is used while testing, where
35 the database is droped and recreated by the plugin.
36 <<<So, you should never fire up this configuration on your production
37 system, or your database might be erased!>>>
39 Hence, you should specify a different url for testing like in the
44 <groupId>de.juplo</groupId>
45 <artifactId>hibernate4-maven-plugin</artifactId>
46 <version>${project.version}</version>
55 <url><![CDATA[jdbc:mysql://localhost/test-db]]></url>
60 Configuration properties, that are set in the <<<configuration>>>-section
61 of the plugin-configuration cannnot be overwritten elsewere (for details
62 see {{Configuration-Method-Precedence}}).
63 You never can overwrite them by accident when specifying a property on
64 the commandline or in your <<<settings.xml>>>.
66 Configuration through maven-properties
68 Alternatively, it is possible, to configure the plugin via maven-properties.
69 Each relevant configuration-option has a corresponding maven-property
70 (for a full list see the {{{./export-mojo.html} Documentation of the export-Mojo}}).
71 These are named after the
72 {{{http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc} Hibernate JDBC Properties}}:
74 * <<<hibernate.connection.driver_class>>>
76 * <<<hibernate.dialect>>>
78 * <<<hibernate.connection.url>>>
80 * <<<hibernate.connection.username>>>
82 * <<<hibernate.connection.password>>>
84 So, instead of writing the hibernate-configuration in the properties-file,
85 like above, you could put it in the <<<properties>>>-section of your
88 Thogether with the plugin-definition from above, the following would
89 be a complete configuration (again, the database-url was overwritten in
90 the plugin-configuration, to be sure to have a separate database for
95 <hibernate.connection.driver_class>org.hsqldb.jdbcDriver</hibernate.connection.driver_class>
96 <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
97 <hibernate.connection.url><![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]></hibernate.connection.url>
98 <hibernate.connection.username>sa</hibernate.connection.username>
99 <hibernate.connection.password></hibernate.connection.password>
109 <groupId>de.juplo</groupId>
110 <artifactId>hibernate4-maven-plugin</artifactId>
111 <version>${project.version}</version>
120 <url><![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]></url>
127 Configuration through the plugin-configuration
129 A third way for configuring the plugin is the plugin-configuration.
130 The relevant configuration-parameters are:
132 * <<<driverClassName>>>
134 * <<<hibernateDialect>>>
142 The equivalent of the configuration from the last section would look
147 <groupId>de.juplo</groupId>
148 <artifactId>hibernate4-maven-plugin</artifactId>
149 <version>${project.version}</version>
158 <driverClassName>org.hsqldb.jdbcDriver</driverClassName>
159 <hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
160 <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url>
161 <username>sa</username>
162 <password></password>
167 The parameter <<hibernateProperties>> (name of the hibernate-properties-file
168 to use, defaults to <<hibernate.properties>>) can only be configured through
171 For more explanations, see the
172 {{{./export-mojo.html} Documentation of the export-Mojo}}.
174 {Configuration-Method-Precedence}
176 The configuration is gathered in a fix order:
178 [[1]] <<<hibernate.properties>>>
180 [[2]] maven-properties
182 [[3]] plugin-configuration
184 If you are in doubt about where a configuration-value comes from, run
185 maven with the {{{./debugging.html}debug-output}} enabled: <<<mvn -X hibernate4:export>>>
186 and be aware, that maven-properties can be overwitten on the command-line,
187 in your <<<~/.m2/settings.xml>>> and in a profile.
189 The plugin-configuration comes last and overwrites everything else.
190 That way, you can be sure, that a configuration-value, that is
191 specified in the plugin-configuration will never be overwritten by any
192 other configuration-method.
195 If you realy need to overwrite plugin-configuration-values with
196 maven-properties, you can use maven-properties in the plugin-configuration:
200 <groupId>de.juplo</groupId>
201 <artifactId>hibernate4-maven-plugin</artifactId>
202 <version>${project.version}</version>
211 <password>${my-password-property}</password>