X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsite%2Fxhtml%2Fpitfalls.xhtml;h=d762b3aec0d30c71bdf8ea9897c30fa4f9da8102;hb=refs%2Ftags%2Fhibernate-maven-plugin-2.0.0;hp=90e09241b60291774dbe854ae30483c86bb1b584;hpb=473c3ef285c19e0f0b85643b67bbd77e06c0b926;p=hibernate4-maven-plugin diff --git a/src/site/xhtml/pitfalls.xhtml b/src/site/xhtml/pitfalls.xhtml index 90e09241..d762b3ae 100644 --- a/src/site/xhtml/pitfalls.xhtml +++ b/src/site/xhtml/pitfalls.xhtml @@ -6,28 +6,34 @@
- hibernate4-maven-plugin by default scans dependencies in the scope
+ hibernate-maven-plugin by default scans dependencies in the scope
compile
. You can configure it to scan dependencies in other
scopes as well. But it scans only direct dependencies. Transitive
dependencies are not scanned for annotated classes. If some of your
annotated classes are hidden in a transitive dependency, you can simply
add that dependency explicitly.
- The default-configuration uses the EXPORT-target of the SchemaExport-Tool.
- If you do not need to create a database with the evaluated schema, you can
- use the NONE- or the SCRIPT-target.
+ The default-configuration exports the created schema to the configured
+ database.
+ Therefore, it needs a valid database-connection and fails, if none is
+ available.
+ If you do not need to export the created schema to a database,
+ you can set the property hibernate.schema.export
to
+ false
.
This can be achieved with the command-line parameter
- -Dhibernate.export.target=SCRIPT
or with the following configuration:
+ -Dhibernate.schema.export=false
or with the following
+ configuration:
<configuration> - <target>SCRIPT</target> + <export>false</export> </configuration>
But even when no database is to be created, hibernate always needs to know - the dialect. Hence, the plugin will fail if this parameter is missing! + the dialect. Hence, the plugin will still fail, if this parameter is also + missing!
@@ -36,7 +42,7 @@
So a tidy maven-developer would usually scope it for runtime
.
- But this will break the execution of the hibernate4-maven-plugin
.
+ But this will break the execution of the hibernate-maven-plugin
.
Since it will not be able to see the needed dependency, it will fail with
an error-message like:
A quick workaround for this error would be, to delete the runtime-constraint for the jdbc-driver-dependency. @@ -70,12 +87,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> @@ -93,42 +111,42 @@ Because otherwise, this dependency will unnecessarily bloat the runtime-dependencies of your project. -+DBUnit fails after execution of hibernate4 was skipped because nothing has changed
+DBUnit fails after execution of hibernate was skipped because nothing has changed
- If hibernate4-maven-plugin skips its excecution, this may lead to errors in + If hibernate-maven-plugin skips its excecution, this may lead to errors in other plugins. For example, when importing sample-data in the automatically created database with the help of the dbunit-plugin, the
CLEAN_INSERT
-operation may fail because of foreign-key-constraints, - if the database was not recreated, because the hibernate4-maven-plugin has + if the database was not recreated, because the hibernate-maven-plugin has skipped its excecution.A quick fix to this problem is, to force - hibernate4-maven-plugin to export the schema every time it is running. + hibernate-maven-plugin to export the schema every time it is running. But to recreate the database on every testrun may noticeable slow down your development cycle, if you have to wait for slow IO.
- To circumvent this problem, hibernate4-maven-plugin signals a skipped - excecution by setting the maven property
$\{hibernate.export.skipped\}
to + To circumvent this problem, hibernate-maven-plugin signals a skipped + excecution by setting the maven property${hibernate.schema.skipped}
totrue
. You can configure other plugins to react on this signal. For example, the dbunit-plugin can be configured to skip its excecution, if - hibernate4-maven-plugin was skipped like this: + hibernate-maven-plugin was skipped like this:<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>dbunit-maven-plugin</artifactId> <configuration> - <skip>${hibernate.export.skipped}</skip> + <skip>${hibernate.schema.skipped}</skip> </configuration> </plugin>The database will not be recreated after a manual drop/clean
If one manually drops the database or removes the hsqldb-files, it will not - be recreated by the hibernate4-maven-plugin, because it cannot detect, that + be recreated by the hibernate-maven-plugin, because it cannot detect, that the database needs to be recreated. This happens, because the plugin will not recreate the database if neither the configuration nor the annotated classes have changed, because an @@ -143,17 +161,17 @@ Otherwise the recreation must be forced:
-mvn hibernate4:export -Dhibernate.export.force=true-The hibernate4:export goal is not executed, when tests are skipped
+mvn hibernate:create -Dhibernate.schema.force=true
- The hibernate4-maven-plugin automatically skips its execution, when
+ The hibernate-maven-plugin automatically skips its execution, when
maven.test.skip
is set to true
. If you need it to be always
executed, you can configure that explicitly like this:
<plugin> <groupId>de.juplo</groupId> - <artifactId>hibernate4-maven-plugin</artifactId> + <artifactId>hibernate-maven-plugin</artifactId> ... <configuration> <skip>false</skip> @@ -166,18 +184,31 @@ mvn hibernate4:export -Dhibernate.export.force=true
If you do not want your dependencies to be scanned for hibernate annotations,
- you can pass -Dhibernate.export.scan_dependencies=none
to maven
+ you can pass -Dhibernate.schema.scan.dependencies=none
to maven
or set scanDependencies
to none
in the configuration
of the plugin like this:
<plugin> <groupId>de.juplo</groupId> - <artifactId>hibernate4-maven-plugin</artifactId> + <artifactId>hibernate-maven-plugin</artifactId> ... <configuration> <scanDependencies>none</scanDependencies> </configuration> </plugin>+
+ If you are working under Windows and get the error-message
+ No annotated classes found in directory C:\projects\X Y Z\path-to-project\target\classes
,
+ but you are really sure, that there are annotated classes in that
+ directory, you are expiriencing a bug, in the scannotation-library, that
+ was closed in version 1.1.0 of the hibernate-maven-plugin.
+
+ + You should consider to upgrade to the latest version of the plugin. + +