DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Databases
  4. Liquibase + Hibernate: Easy and Solid Database Migration

Liquibase + Hibernate: Easy and Solid Database Migration

Peter Karussell user avatar by
Peter Karussell
·
Jun. 21, 10 · Interview
Like (0)
Save
Tweet
Share
25.25K Views

Join the DZone community and get the full member experience.

Join For Free

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:

dom4j-1.6.1.jar
h2-1.2.137.jar #or your prefered jdbc database driver
hibernate-annotations-3.5.1-final.jar
hibernate-commons-annotations-3.2.0.final.jar
hibernate-core-3.5.1-final.jar
hibernate-jpa-2.0-api-1.0.0.final.jar
slf4j-api-1.6.0.jar

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 \
--baseurl=hibernate:src/main/resources/hibernate.cfg.xml

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:

<dependency>
<groupid>org.hibernate</groupid>
<artifactid>hibernate-core</artifactid>
<version>3.5.1-final</version>
</dependency>
<dependency>
<groupid>org.hibernate</groupid>
<artifactid>hibernate-annotations</artifactid>
<version>3.5.1-final</version>
</dependency>

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

Hibernate Database Liquibase

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Custom Validators in Quarkus
  • Building the Next-Generation Data Lakehouse: 10X Performance
  • Front-End Troubleshooting Using OpenTelemetry
  • Important Data Structures and Algorithms for Data Engineers

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: