Important JPA and Hibernate Properties in Spring Boot
Fast recall
Quick revision
Core answer
ddl-auto, show-sql, open-in-view, database-platform) and `spring.jpa.properties.hibernate.*` for raw Hibernate properties (jdbc.batch_size, order_inserts, format_sql, cache.*). The four that matter for production are: `ddl-auto=validate` or none (never update), `open-in-view=false` to avoid hidden N+1 queries in the view layer, `format_sql=true` only in development, and `jdbc.batch_size=50` with order_inserts=true to enable batch INSERTs. Leaving open-in-view=true (Boot's default) is the most common performance bug in Spring JPA apps — it keeps the Hibernate session open for the entire HTTP request, silently firing queries whenever lazy associations are touched in JSON serialization.Whether you know the difference between Boot's JPA namespace and Hibernate-native properties, and whether you can identify production-critical settings
Leaving `open-in-view=true`; using `ddl-auto=update` in production; setting `show-sql=true` in production (log volume explosion)
Call out that `open-in-view=true` is the single most common Spring JPA performance bug, and explain how `jdbc.batch_size` interacts with `IDENTITY` column strategy (it disables batching)
Interview-ready guide
Interview answer
Two configuration namespaces
spring.jpa.*— Boot's own namespace (ddl-auto,show-sql,open-in-view)spring.jpa.properties.hibernate.*— pass-through for raw Hibernate (batching, caching, dialect specifics)
The four production settings that matter
1. `spring.jpa.hibernate.ddl-auto=validate` (or `none`)
- Never
updatein production validatefails fast on schema drift;noneis correct when Flyway/Liquibase owns schema
2. `spring.jpa.open-in-view=false` — the silent N+1 amplifier
- Boot defaults to
truefor backward compatibility - Keeps Hibernate session open during JSON serialization → lazy loads fire inside Jackson
- Doesn't show up in logs unless SQL logging is on
- Disable it, then DTO-project inside the transaction or use
JOIN FETCH/@EntityGraph
3. JDBC batching — three properties together
hibernate.jdbc.batch_size=50+order_inserts=true+order_updates=true- Gotcha:
@GeneratedValue(strategy=IDENTITY)disables batching (Hibernate needs the key per insert) - On Postgres/Oracle use
SEQUENCEfor batchable inserts
4. `show-sql` in production is a throughput bug
- Every query becomes a log line — real I/O cost
- Use DB slow-query log or APM for production SQL observability
Dev-only debugging
logging.level.org.hibernate.orm.jdbc.bind=TRACE(Hibernate 6) shows actual bound parameter values instead of?
Important JPA and Hibernate Properties in Spring Boot
Direct Answer
Spring Boot exposes JPA config under two prefixes: spring.jpa.* for Boot-managed settings (ddl-auto, show-sql, open-in-view, database-platform) and spring.jpa.properties.hibernate.* for raw Hibernate properties (jdbc.batch_size, order_inserts, format_sql, cache.*). The four that matter for production are: ddl-auto=validate or none (never update), open-in-view=false to avoid hidden N+1 queries in the view layer, format_sql=true only in development, and jdbc.batch_size=50 with order_inserts=true to enable batch INSERTs. Leaving open-in-view=true (Boot's default) is the most common performance bug in Spring JPA apps — it keeps the Hibernate session open for the entire HTTP request, silently firing queries whenever lazy associations are touched in JSON serialization.
Common Mistakes & Pitfalls
Leaving open-in-view=true; using ddl-auto=update in production; setting show-sql=true in production (log volume explosion)
Check your understanding
Answer these without looking back at the article.
- Why does `@GeneratedValue(strategy=IDENTITY)` disable Hibernate batch inserts?
- What exactly happens when `open-in-view=true` and Jackson serializes a lazy collection?
- When would you use `@EntityGraph` vs a JPQL `JOIN FETCH`?
- How do you migrate an existing codebase from `open-in-view=true` to `false` safely?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.