Hibernate / Hibernate 7 Basics Interview Questions
How does Hibernate 7 handle schema validation and generation (hbm2ddl)?
Hibernate can validate or generate the DB schema from entity mappings. Controlled by hibernate.hbm2ddl.auto.
| Value | Behaviour | Use in |
|---|---|---|
| none | No schema action | Production (use Flyway/Liquibase) |
| validate | Validates entity mappings match schema; fails on mismatch | Production safety check |
| update | Adds missing columns/tables; never drops | Development (risky in production) |
| create | Drops and recreates all tables on startup | Development/testing |
| create-drop | Creates on startup; drops on SessionFactory close | Unit tests |
# Recommended production setup: spring: jpa: hibernate: ddl-auto: none # Hibernate does NOT touch schema flyway: enabled: true # Flyway manages schema with versioned migrations locations: classpath:db/migration # Development: spring: jpa: hibernate: ddl-auto: create-drop # fresh schema each run # Flyway migration files: # db/migration/V1__create_products_table.sql # db/migration/V2__add_category_to_products.sql
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
