Skip to content

When an application contains multiple DataSource beans, EntityManagerFactoryBuilder will default ddl-auto to a value that may only be appropriate for the primary DataSource #44516

Closed
@randomComitter

Description

@randomComitter

After updating Spring Boot from 3.3.5 to 3.4.3, the default ddl-auto create-drop will be applied to the non-embedded database if project has two databases, one of them is an embedded db and no explicit value is set for spring.jpa.hibernate.ddl-auto in application properties.
Is this a bug or an intended behavior?

The current documentation for Database Initialization mentions the following:

If an embedded database is identified and no schema manager (Flyway or Liquibase) has been detected, ddl-auto defaults to create-drop. In all other cases, it defaults to none.

which gives impression that create-drop will be applied by default only to the embedded database.
However, sometime between Spring Boot 3.3.5 and 3.4.3 a change was made so that default value create-drop for spring.jpa.hibernate.ddl-auto was applied to all data sources whether they were embedded or not (if at least one of them was embedded), which is dangerous behaviour and can lead to unexpected data loss in production databases.

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions