While upgrading my blog software Cilla to Java 8 and Hibernate 4, I found out that the old
hibernate3-maven-plugin refused to create
schema.sql files. Well, it wasn't really surprising. The name of the plugin already implied that the plugin won't play with the next major release of Hibernate.
I could not spot an official update of the plugin. Instead, I found Kai Moritz new Hibernate 4 maven plugin, which turned out to be very useful.
One key feature is to set up and initialize a local database for unit testing. I don't need this feature for Cilla (yet 😉). All I need is a
hbm2ddl style generation of a SQL schema file for setting up new instances of my blog software from scratch. It turned out that the plugin was easily configured that way, and so it got almost a drop-in replacement for the old plugin.
This is what the
<plugins> section of the project's pom file looks like:
target set to
schema.sql file is quietly generated while building the project. If set to
SCRIPT, a copy will be dumped to stdout.
type only generates create statements of the database. The default is
BOTH, which creates drop and create statements.
Since no actual database is created, there is no need to add
A list of all configuration options can be found here. The plugin is available at Maven Central.