3 * Configuration through a hibernate.properties-File
5 The most simple way to configure the plugin is, to put all the
6 hibernate-configuration in a <<hibernate.properties>>-file on your
7 classpath. Put the file in the <<<resources>>>-folder. Maven will put
8 it in the <<<class>>>-folder of your webapp, where it will be picked up
9 by this plugin as well as by Hibernate 4.
11 Doing so, the only additionally configuration needed, to activat the plugin
12 is the following entry in the <<<plugins>>>-section of your <<<pom.xml>>>:
16 <groupId>de.juplo</groupId>
17 <artifactId>hibernate4-maven-plugin</artifactId>
18 <version>${project.version}</version>
29 But be aware, that in this case the database-url, that is
30 build in the application is the same that is used while testing, where
31 the database is droped and recreated by the plugin.
32 <<<So, you should never fire up this configuration on your production
33 system, or your database might be erased!>>>
35 Hence, you should specify a different url for testing like in the
40 <groupId>de.juplo</groupId>
41 <artifactId>hibernate4-maven-plugin</artifactId>
42 <version>${project.version}</version>
51 <url><![CDATA[jdbc:mysql://localhost/test-db]]></url>
56 Configuration properties, that are set in the <<<configuration>>>-section
57 of the plugin-configuration cannnot be overwritten elsewere (for details
58 see {{Configuration-Method-Precedence}}).
59 You never can overwrite them by accident when specifying a property on
60 the commandline or in your <<<settings.xml>>>.
62 * Configuration through maven-properties
64 Alternatively, it is possible, to configure the plugin via maven-properties.
65 Each relevant configuration-option has a corresponding maven-property
66 (for a full list see the {{{./export-mojo.html} Documentation of the export-Mojo}}).
67 These are named after the
68 {{{http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc} Hibernate JDBC Properties}}:
70 * <<<hibernate.connection.driver_class>>>
72 * <<<hibernate.dialect>>>
74 * <<<hibernate.connection.url>>>
76 * <<<hibernate.connection.username>>>
78 * <<<hibernate.connection.password>>>
80 So, instead of writing the hibernate-configuration in the properties-file,
81 like above, you could put it in the <<<properties>>>-section of your
84 Thogether with the plugin-definition from above, the following would
85 be a complete configuration (again, the database-url was overwritten in
86 the plugin-configuration, to be sure to have a separate database for
91 <hibernate.connection.driver_class>org.hsqldb.jdbcDriver</hibernate.connection.driver_class>
92 <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
93 <hibernate.connection.url><![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]></hibernate.connection.url>
94 <hibernate.connection.username>sa</hibernate.connection.username>
95 <hibernate.connection.password></hibernate.connection.password>
105 <groupId>de.juplo</groupId>
106 <artifactId>hibernate4-maven-plugin</artifactId>
107 <version>${project.version}</version>
116 <url><![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]></url>
123 * Configuration through the plugin-configuration
125 A third way for configuring the plugin is the plugin-configuration.
126 The relevant configuration-parameters are:
128 * <<<driverClassName>>>
130 * <<<hibernateDialect>>>
138 The equivalent of the configuration from the last section would look
143 <groupId>de.juplo</groupId>
144 <artifactId>hibernate4-maven-plugin</artifactId>
145 <version>${project.version}</version>
154 <driverClassName>org.hsqldb.jdbcDriver</driverClassName>
155 <hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
156 <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url>
157 <username>sa</username>
158 <password></password>
163 The parameter <<hibernateProperties>> (name of the hibernate-properties-file
164 to use, defaults to <<hibernate.properties>>) can only be configured through
167 For more explanations, see the
168 {{{./export-mojo.html} Documentation of the export-Mojo}}.
170 {Configuration-Method-Precedence}
172 The configuration is gathered in a fix order:
174 [[1]] <<<hibernate.properties>>>
176 [[2]] maven-properties
178 [[3]] plugin-configuration
180 If you are in doubt about where a configuration-value comes from, run
181 maven with the {{{./debugging.html}debug-output}} enabled: <<<mvn -X hibernate4:export>>>
182 and be aware, that maven-properties can be overwitten on the command-line,
183 in your <<<~/.m2/settings.xml>>> and in a profile.
185 The plugin-configuration comes last and overwrites everything else.
186 That way, you can be sure, that a configuration-value, that is
187 specified in the plugin-configuration will never be overwritten by any
188 other configuration-method.
191 If you realy need to overwrite plugin-configuration-values with
192 maven-properties, you can use maven-properties in the plugin-configuration:
196 <groupId>de.juplo</groupId>
197 <artifactId>hibernate4-maven-plugin</artifactId>
198 <version>${project.version}</version>
207 <password>${my-password-property}</password>