Friday, May 30, 2008

hibernate3-maven-plugin and hbm2ddl

I've wrestled with this quite a bit in the past few days. I had a difficult time figuring out some of the settings from the plugin site. Here's what I finally ended up with that works properly.


<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>
jpaconfiguration
</implementation>
</component>
</components>
<componentProperties>
<drop>true</drop>
<jdk5>true</jdk5>
<outputfilename>schema.ddl</outputfilename>
<persistenceunit>Developer</persistenceunit>
<propertyfile>target/classes/jdbc.properties</propertyfile>
<skip>${maven.test.skip}</skip>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>
</dependencies>
</plugin>

5 comments:

jon said...

where does your persistence.xml live? i keep mine in src/main/resources but it keeps complaining about not finding one in META-INF/persistence.xml

:(

Unknown said...

/src/main/resources/META-INF/persistence.xml

jon said...

that did the trick. :)

Unknown said...

thank you very much. finally it does what i wanted. The hibernate.property file is important to provide connection details. mine looks like this:
hibernate.connection.username=user
hibernate.connection.password=pwd
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.connection.url=jdbc\:mysql\://localhost/MyDatabase

Unknown said...

This plugin is really difficult to configure, and this blog helped me a lot. Thanks!