Wednesday, February 9, 2011

About Hibernate 3 plugin for Maven

In one of my previous entries, I had something really cool on my POM, which basically generated the DataBase based on my Entyties (or Domain objects), and that was the Hibernate 3 plugin for Maven
As you will see on the official documentation for that plugin, you can do a bunch of things, but it doesn't says anything about, generating Java classes based on the Tables, right? In other words, if I want my model java files (obtained by reveng) compiled, you don't need to run hbm2hbmxml.
I found the solution to this issue (unfortunately is not documented, and that's why you see it here):

Plugin configuration
hibernate.properties
hibernate.connection.username=root
hibernate.connection.password=secretit0
hibernate.connection.url=jdbc:mysql://127.0.0.1:3306/little_store
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.default_schema=little_store

model_reveng.xml
Then the last step is executing Maven:
mvn hibernate3:hbm2java

And we're ready to roll! :)

No comments:

Post a Comment