Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Hibernate’s ddl-auto=update can change a database schema during application startup, but its documented behavior alone does not explain why a production table ended up with two columns. Treat the cause as unconfirmed until you compare the deployed mapping, database catalog, migration history, startup DDL, and deployment configuration. Preserve the data, identify the authoritative column, then correct the schema with a reviewed migration.

What ddl-auto=update does—and what it does not prove

Spring Boot exposes Hibernate schema generation through spring.jpa.hibernate.ddl-auto. The documented values are none, validate, update, create, and create-drop. The default is contextual: Spring Boot defaults to create-drop for an embedded database when no Flyway or Liquibase schema manager is detected; otherwise it defaults to none. It does not generally default production databases to update. See Spring Boot’s database initialization documentation.

Hibernate describes update as exporting schema elements it considers missing and altering incorrect column types. In practical terms, Hibernate compares mappings with the schema it sees and may issue schema changes during initialization. That description does not establish which SQL ran in this incident, which database or dialect was involved, or why two columns remained. The Hibernate automatic schema export documentation describes the feature, not the cause of this specific outcome.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Whether the setting was present in staging, production, or both—and which application version actually connected to production—must be established from configuration and deployment records. The title alone cannot show that Hibernate created both columns.

Investigate why two columns exist before changing either

Several explanations are plausible, but none is confirmed without incident evidence. A property or explicit column mapping may have been renamed; a physical naming strategy may have changed; staging and production may have started with different schema states; different application versions may have connected to the same database; or another process may have managed DDL independently.

Build a timeline and compare the exact deployed build with the live schema. Collect:

  • The entity annotations or XML mappings and the configured physical naming strategy for the deployed version.
  • Spring Boot, Hibernate, database, and dialect versions, along with the database and schema/catalog involved.
  • The database catalog’s exact table and column names, types, nullability, constraints, indexes, and the data in both columns.
  • Migration history, deployment order, relevant application configuration, and Hibernate startup SQL or DDL logs.
  • Evidence of which columns the running application reads and writes, including whether multiple application versions were active.

Use the catalog and logs to determine what changed and when. A mapping difference or migration record may explain the duplicate; do not infer one merely from the column names.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix the production schema without losing data

  1. Stop further automatic mutation. Disable Hibernate schema changes for the affected production profile while preserving relevant logs and taking a recoverable backup or snapshot under your normal operational procedures.
  2. Establish the actual state. Inspect the catalog and compare both columns’ definitions and contents with the exact deployed mapping. Review migration records and startup logs to establish whether the columns appeared together or at different times.
  3. Determine which column is canonical. Trace reads, writes, and existing values before deciding. If values must be copied, merged, or reconciled, design and test that as a reviewed migration with a recovery plan. Do not drop a column just because its name looks obsolete.
  4. Apply a reviewed migration. Make the intended schema change through an incremental migration after confirming how the application and data will behave during deployment. Verify the result against the catalog and the application’s expected mapping.
  5. Use a non-mutating Hibernate mode in deployed profiles. Choose validate if startup schema checks are desired, or none to disable Hibernate schema action. Confirm the behavior against the project’s actual dependency versions and environment.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use one mechanism to manage schema changes

Hibernate’s ORM documentation says: “Although the automatic schema generation is very useful for testing and prototyping purposes, in a production environment, it’s much more flexible to manage the schema using incremental migration scripts.” See the Hibernate ORM schema generation guidance.

Spring Boot identifies Flyway and Liquibase as higher-level migration tools and advises using a single mechanism to create and initialize the schema when one is selected. Avoid having Hibernate schema generation and a migration tool independently initialize or mutate the same database. See Spring Boot’s database initialization guidance.

Flyway documents migration scripts for DDL operations such as CREATE, ALTER, and DROP. That capability does not guarantee that a particular migration is safe or reversible; safety depends on its contents, deployment sequence, and recovery plan. See Flyway’s migration concepts.

Choose a migration tool for your workflow

The cited documentation does not establish that Flyway or Liquibase is universally superior. Evaluate either against the database and SQL dialect you use, how changes are authored and reviewed, how migration order and history are recorded, and how deployment compatibility, recovery, rollback, and schema drift are handled in your CI/CD process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The cited Spring Boot and Hibernate documentation is rolling documentation. For a specific incident, check the documentation and behavior that match the application’s actual Spring Boot, Hibernate, database, and dialect versions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.