Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hibernate native image support broken by HHH-17643 #32311

Closed
sdeleuze opened this issue Feb 22, 2024 · 1 comment
Closed

Hibernate native image support broken by HHH-17643 #32311

sdeleuze opened this issue Feb 22, 2024 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Milestone

Comments

@sdeleuze
Copy link
Contributor

sdeleuze commented Feb 22, 2024

HHH-17643 breaks Spring Framework native image support with Hibernate 6.4.3+ and 6.2.21+ as it breaks the substitution shipped with Spring Framework with the following error message:

Error: Could not find target method: public static org.hibernate.bytecode.spi.BytecodeProvider org.springframework.orm.jpa.vendor.Target_BytecodeProviderInitiator.buildBytecodeProvider(java.lang.String)	

Such breakage in a patch release, even if triggered by a change on an internal Hibernate API, is unfortunate given the ongoing effort between the 2 teams to try to collaborate on a suitable solution with synchronisation on both sides to avoid such unanticipated breakage, as it has been identified as a fragile (but required) way to make Hibernate compatible with Spring on native.

In practice, that means Spring Boot 3.2.3 and 3.1.9 applications based respectively on Spring Framework 6.1.4 and 6.0.17 will have to downgrade Hibernate version on native to respectively Hibernate 6.4.2 and 6.2.20.

The Spring Framework upcoming fix in 6.1.5 and 6.0.18 will consist in 2 parts:

  • Make the Target_BytecodeProviderInitiator substitution more lenient by checking the related method exists before applying it.
  • Exclude the Bytebuddy BytecodeProvider on native by shipping a native-image-properties with -H:ServiceLoaderFeatureExcludeServices=org.hibernate.bytecode.spi.BytecodeProvider.

The follow-up #32314 Spring Framework 6.2 issue has ben created to remove completely the 2 Hibernate substitutions when Hibernate 6.4.5 will be released with HHH-17568 fixed.

@sdeleuze sdeleuze added in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression for: backport-to-6.0.x Marks an issue as a candidate for backport to 6.0.x labels Feb 22, 2024
@sdeleuze sdeleuze added this to the 6.1.5 milestone Feb 22, 2024
@sdeleuze sdeleuze self-assigned this Feb 22, 2024
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-6.0.x Marks an issue as a candidate for backport to 6.0.x labels Feb 22, 2024
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Feb 22, 2024
This commit adapts Hibernate native support to handle
the changes performed as part of HHH-17643 which impacts
Hibernate versions 6.4.3+ and 6.2.21+.

It ignores the BytecodeProvider services loaded by the
service loader feature in order to default to the
"no-op" provider with native, and makes the substitutions
more lenient when a substituted field or method does not
exists.

spring-projectsgh-32314 is expected to remove the need for such
substitutions which are not great for maintainability
by design.

Closes spring-projectsgh-32311
@sdeleuze
Copy link
Contributor Author

As mentioned in Spring Boot 3.2.3 release notes:

This release upgrades to Hibernate 6.4.4.Final. While it contains a number of valuable bug fixes, it does not work correctly in a native image. If you are using GraalVM, Hibernate should be temporarily downgraded to 6.4.2.Final using the hibernate.version property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

1 participant