{{ !articles[0].partner.isSponsoringArticle ? "Platinum" : "Portal" }} Partner

Liquibase + Hibernate: Easy and Solid Database Migration

As I pointed out earlier liquibase is a stable and nice migration tool for SQL databases in the Java land. The problem I had is that I couldn’t get it working with hibernate while using annotations.

Now just for my personal memory here are the steps to get it working. Download liquibase 1.9.5 (couldn’t get it working with 2.0.0 :-( ) and put the following libs in the liquibase/lib folder:

h2-1.2.137.jar #or your prefered jdbc database driver

You will need to put the 4 hibernate jars into the classpath parameter, too. To do a diff and update the changelog file via the command line do the following:

liquibase --logLevel=FINE \
--driver=org.h2.Driver \
--classpath=$CP \
--url=jdbc:h2:~/.myapp/h2db \
--username=sa \
--password=tmp \
--changeLogFile=src/main/resources/dbchangelog.xml \
diffChangeLog \

This means you compare the ‘old’ database with the new hibernate config. If you have problems while set-up you can look directly into the source file.

BTW: here is the pom snippet for the hibernate deps:


From http://karussell.wordpress.com/2010/06/20/liquibase-hibernate-annotations-easy-and-solid-database-migration/

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks