rewrite-spring icon indicating copy to clipboard operation
rewrite-spring copied to clipboard

2.4-2.5: Hibernate and data.sql

Open fabapp2 opened this issue 3 years ago • 1 comments

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.sql exists in classpath root OR spring.sql.init.data-locations is set.

Recipe

  • Inform the user about the changed initialization order and when to set spring.jpa.defer-datasource-initialization to true

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

fabapp2 avatar Jan 05 '22 12:01 fabapp2

This requires openrewrite/rewrite#1315

pway99 avatar Jan 11 '22 22:01 pway99