[EN] Modern schema management with Hibernate 7 and Jakarta Persistence

Julian | Apr 24, 2026 min read

Now that we have understood the architecture and the lifecycle, we now move on to the practical implementation. In the modern Java world – especially with Spring Boot 3.4+ – a lot of things are “convention over configuration”. But if you blindly rely on defaults, you will build up technical debt before the first line of business logic goes live.

In this part we’ll look at how to optimally configure Hibernate 7 via the application.properties and what pitfalls you need to be aware of.

The foundation: dialects and database connection

Previously, specifying the exact SQL dialect (e.g. PostgreSQL95Dialect) was mandatory. With Hibernate 7, the framework has become significantly smarter. It usually automatically detects the database version when establishing a connection and selects the optimal dialect itself.

# Meistens reicht die JDBC-URL aus:
spring.datasource.url=jdbc:postgresql://localhost:5432/production_db
spring.datasource.username=db_user
spring.datasource.password=secure_password

Tip: Avoid explicitly specifying spring.jpa.database-platform unless you have made very specific adjustments to the dialect. Hibernate 7 does an excellent job with auto-detection here.

Schema Management: The Sharp Blade

The property spring.jpa.hibernate.ddl-auto is probably the most dangerous setting in your stack. It decides whether Hibernate changes the database schema independently.

  • update: Convenient for local development. Hibernate adds columns and tables. Caution: It does not delete stale columns and does not recognize renames (leads to data corpses).
  • validate: The recommendation for production. When Hibernate starts, it checks whether the entities match the schema. If not, the start is aborted. This prevents runtime errors.
  • none: Hibernate completely ignores the schema. Ideal if you use migration tools like Liquibase or Flyway (which you should).
# Lokal (Dev-Profil)
spring.jpa.hibernate.ddl-auto=update

# Produktion (Prod-Profil)
spring.jpa.hibernate.ddl-auto=validate

Visibility: Logging without flying blind

If Hibernate doesn’t do what you expect, you need to see what’s happening “on the wire”. Do not use spring.jpa.show-sql=true for this, as this writes directly to System.out and bypasses the logging framework. Instead, use targeted logger categories.

In Hibernate 7, some logging paths have been stabilized. To see the SQL statements and the associated parameters, configure the following:

# SQL-Statements loggen
logging.level.org.hibernate.SQL=DEBUG

# Die tatsächlichen Werte der Parameter (?) anzeigen
logging.level.org.hibernate.orm.jdbc.bind=TRACE

# SQL schön formatiert ausgeben (lesbarer, aber längere Logs)
spring.jpa.properties.hibernate.format_sql=true

Naming Strategies: Java-Welt vs. SQL-Welt

In Java we use camelCase, in databases snake_case is the standard. Hibernate 7 uses the CamelCaseToUnderscoresNamingStrategy by default. This means that a lastLogin field automatically becomes the last_login column.

If you need to use a legacy schema where the columns have exactly the same names as the Java fields, you can adjust this:

# Falls Java-Feldname = DB-Spaltenname gelten soll
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

Important new features in Hibernate 7

With the switch to Hibernate 7 and Jakarta Persistence 3.2, some old traditions have been cut off. If you are migrating from older versions, keep the following points in mind:

  1. Id generators: The behavior of @GeneratedValue(strategy = GenerationType.AUTO) has been refined. Hibernate 7 attempts to use native database sequences more efficiently.
  2. Removal of Legacy Properties: Many old hibernate.* properties have been removed or replaced with standardized jakarta.persistence.* properties. Spring Boot abstracts most things under spring.jpa.properties.*, but a look at the official migration guides is mandatory for complex setups.

Conclusion: Stay in control

Hibernate 7’s configuration is now very beginner-friendly thanks to Spring Boot, but for us as senior engineers, “kinda works” isn’t enough. Use validate in production, use clean logging instead of show-sql and leave schema management in professional projects to tools like Flyway.

In the next part of the series, we’ll look at a topic that is often neglected until it’s too late: Performance. We talk about the N+1 problem, fetch strategies and how to get Hibernate 7 to issue highly efficient queries.