liquibase-hibernate integration is not practical

I did a bit of research and finally got it working but even then decided the liquibase-hibernate integration wasn’t providing enough value. I’m very hopeful that in the future it will refine some of these issues but for now it’s a no go.

Our environment: liquibase, hibernate, oracle, maven

  • The hibernate annotation to liquibase generation is currently only generating the table DDL without the validation or creating the sequences to go with the tables.
  • The generation overwrites the file instead of intelligently appending to an exsisting file so it requires an extra step of copy/paste to the real liquibase file
  • The hibernate/liquibase plugin uses ant. When the ant task configured into maven there's no way to run it independantly of the build phases w/o configuring a profile
  • Maven profiles are not inherited, so they must be copy pasted into every model module and can't be put into pom-model.
  • A hibernate.cfg.xml must exist in the model module for the sole purpose of the liquibase-hibernate conversion a changelog file must exist in the model module for the sole purpose of generating the liquibase xml to copy from.
  • The tool will preform a diff against the database, not against an exsisting changelog file so a liquibase/hibernate must connect to that database to compare the hibernate annotations against and then only the difference is put into the changelog file.

Those are all very good points.  I will create a feature request detailing them so they do not get lost.  I do consider the hibernate diff support (and all diff support) a secondary support tool, rather than something that should be relied on.  That is not to say that we should not make it as seamless as possible, but I do put feature requests to the core update support ahead of diff improvements (though you or anyone else is certainly welcome to contribute improvements as you see fit).

Nathan

It is http://liquibase.jira.com/browse/CORE-395 for those following along at home…

Nathan

Thank you very much!

I do agree that tools like this should be secondary to the liquibase core. I think currently generated ddl tools are considered second class citizens because currently they can’t be relied on. I am looking forward to the day when I can fully gen my DDL from my hibernate config and truely hand off my database interaction to the frameworks.

@otatop
antrun can run independently the following way (just leave out the executions tag and use ‘mvn antrun:run’). The drawback is that there is only one ‘default’ execution:

maven-antrun-plugin

@Nathan Voxland
It would also be nice if a NamingStrategy could be set. This can not be done in the hibernate.cfg.xml, but should be set in the Hibernate Configuration object.

In a perfect world I’d really like to have liquibase be able to diff my hibernate annotations with the database (hibernate does have a utility for that) and store the results of that as a changeset in my liquibase.xml. Then all I’d have to do is change my annotations and the rest would be taken care of for me.

That is the goal of the hibernate support.  Just not quite there yet.  We do leverage the hbm2ddl classes that come with hibernate as a base, but haven’t gotten through comparing and understanding all the data it gives us. 

Nathan

Can we do what otatop said now ?

"In a perfect world I’d really like to have liquibase be able to diff my hibernate annotations with the database (hibernate does have a utility for that) and store the results of that as a changeset in my liquibase.xml. Then all I’d have to do is change my annotations and the rest would be taken care of for me."

Can we do this in the current release ?

Yes, we are also looking for this feature!