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 There are some seldom used parameters, that can only be configured throug
166 * <<delimiter>> the delimiter used in the generated sql-script
168 * <<format>> wether the generated sql-script is formatted, or not
170 * <<hibernateProperties>> name of the hibernate-properties-file
172 * <<outputFile>> name of the generated sql-script
174 * <<target>> create database or generate sql-script or both
176 * <<type>> create or drop the database or do both or nothing
177 (just validate the annotation-configuration)
179 For explanations, see the
180 {{{./export-mojo.html} Documentation of the export-Mojo}}.
182 {Configuration-Method-Precedence}
184 The configuration is gathered in a fix order:
186 [[1]] <<<hibernate.properties>>>
188 [[2]] maven-properties
190 [[3]] plugin-configuration
192 If you are in doubt about where a configuration-value comes from, run
193 maven with the {{{./debugging.html}debug-output}} enabled: <<<mvn -X hibernate4:export>>>
194 and be aware, that maven-properties can be overwitten on the command-line,
195 in your <<<~/.m2/settings.xml>>> and in a profile.
197 The plugin-configuration comes last and overwrites everything else.
198 That way, you can be sure, that a configuration-value, that is
199 specified in the plugin-configuration will never be overwritten by any
200 other configuration-method.
203 If you realy need to overwrite plugin-configuration-values with
204 maven-properties, you can use maven-properties in the plugin-configuration:
208 <groupId>de.juplo</groupId>
209 <artifactId>hibernate4-maven-plugin</artifactId>
210 <version>${project.version}</version>
219 <password>${my-password-property}</password>