2.4-2.5: Hibernate and data.sql
blocked-by openrewrite/rewrite/issues/1315
Release Notes
By default, data.sql scripts are now run before Hibernate is initialized. This aligns the behavior of basic script-based initialization with that of Flyway and Liquibase. If you want to use data.sql to populate a schema created by Hibernate, set spring.jpa.defer-datasource-initialization to true. While mixing database initialization technologies is not recommended, this will also allow you to use a schema.sql script to build upon a Hibernate-created schema before it’s populated via data.sql.
- Requires user decision!
- Must be applied after #127
Condition
data.sqlexists in classpath root ORspring.sql.init.data-locationsis set.
Recipe
- Inform the user about the changed initialization order and when to set
spring.jpa.defer-datasource-initializationtotrue
related issues: #134 - beans depending on database initialization might be affected by spring.jpa.defer-datasource-initialization, see https://docs.spring.io/spring-boot/docs/2.5.0/reference/html//howto.html#howto.data-initialization.dependencies.depends-on-initialization-detection
This requires openrewrite/rewrite#1315