On this page

Liquibase Diff Not Working with Hibernate? Here’s What’s Actually Going Wrong (and How to Fix It)

Liquibase diff not working with Hibernate? Learn why schema mismatches happen and how to fix issues in Spring Boot and CI/CD pipelines.

If you’ve ever run a Liquibase diff with Hibernate and thought “this doesn’t look right” — you’re not alone.
A lot of developers hit this issue, especially in Spring Boot projects, where Hibernate quietly manages schema while Liquibase tries to track changes properly.
At first, it feels like a bug.
But in most cases, it’s not.
It’s a mismatch in how these tools think about your database.
In this guide, I’ll break down:

  • Why Liquibase diff behaves strangely with Hibernate
  • What’s actually happening behind the scenes
  • How to fix it properly (not just patch it)
  • What to do in real CI/CD setups

The Real Problem

Hibernate and Liquibase are solving two different problems.

  • Hibernate → helps you generate schema from code
  • Liquibase → helps you manage schema changes safely

The trouble starts when you try to use both without clear boundaries.
For example:

  • Hibernate generates: userName
  • Database already has: user_name

To you, it’s the same thing.
To Liquibase, it’s a change.
Now multiply that across tables, columns, constraints — and suddenly your diff output is full of unexpected changes.


What Liquibase Is Actually Doing

When you run a diff, Liquibase:

  1. Reads your current database
  2. Builds a snapshot
  3. Compares it with expected structure
  4. Generates a changelog

Now here’s the catch:
👉 Hibernate doesn’t guarantee the same structure every time
👉 Liquibase expects consistency
That gap is where things break.

Common Reasons This Happens

From real-world experience, these are the usual suspects:

  • Naming mismatch (camelCase vs snake_case)
  • Different data types between Hibernate and DB
  • Hibernate auto-updating schema (ddl-auto=update)
  • Manual DB changes done outside migrations

This is exactly why many teams run into Liquibase + Hibernate conflicts without realizing the root cause.


Hibernate vs Liquibase (Simple Truth)

If you remember just one thing:
Don’t let both control your schema at the same time

Fix #1: Stop Hibernate from Changing Your Database

This is the most important step.

spring:
  jpa:
    hibernate:
      ddl-auto: none

If this is not set correctly, Hibernate will keep modifying your schema behind the scenes — and Liquibase will keep detecting “changes”.

Fix #2: Use Liquibase as the Single Source of Truth

Once Hibernate stops interfering:

  • Generate your baseline:

liquibase generateChangeLog

  • Commit it
  • From now on, all changes go through Liquibase

No shortcuts.

Fix #3: Be Consistent with Naming

Pick one style and stick to it:

  • snake_case (recommended for DB)
  • or camelCase (if you must)

Mixing both is one of the biggest reasons diffs look broken.


Fix #4: Always Review Diff Output

Never trust this blindly:
liquibase diffIt’s a tool — not a decision-maker.
Always check:

  • Are these real changes?
  • Or just naming/type differences?

Debugging Checklist (Use This in Real Projects)

If things still look off:

  • Is ddl-auto disabled?
  • Are entities and DB aligned?
  • Any manual DB changes?
  • Same naming strategy everywhere?
  • Same environment configs?

Most issues come down to one of these.


Real Scenario (This Happens More Than You Think)

We saw this in a CI/CD pipeline:

  • Liquibase started generating 100+ changes
  • Nothing major had actually changed

Root cause?

  • Hibernate naming mismatch
  • Someone updated schema manually in staging

Fix:

  • Disabled Hibernate auto DDL
  • Enforced Liquibase-only changes
  • Cleaned up schema

After that — clean diffs, stable deployments.

Best Practices Going Forward

  • Treat your database like code
  • Never mix auto schema + migrations
  • Run Liquibase in CI/CD
  • Validate changes in staging
  • Keep environments consistent

If you’re looking for a reliable Liquibase + Hibernate setup, this is the only way that works long-term.


FAQ

Why does Liquibase diff show changes even when nothing changed?

Because Hibernate and Liquibase interpret schema differently (especially naming and types).

Can I use Hibernate and Liquibase together?

Yes — but only if Hibernate is not modifying the schema.

Is Liquibase diff reliable?

Yes, but only when your schema is consistent and controlled.

What is schema drift?

Changes made directly in the database without version control.

Read More on KubeBlogs

If you're exploring DevOps, Kubernetes, and cloud infrastructure, these guides will help you go deeper:

Conclusion

This issue is not really about Liquibase or Hibernate being wrong.
It’s about how they are used together.
Hibernate is great for development.
Liquibase is built for controlled, production-safe changes.
Once you clearly separate their roles, the problem disappears.