Hello. I am using Spring Boot version 3.0.7
Preconditions:
I have a hibernate entity that is using fetch = FetchType.LAZY
@JoinTable(name = "user_identities", joinColumns = {
@JoinColumn(name = "user_id")}, inverseJoinColumns = {
@JoinColumn(name = "user_identity_id")})
@OneToMany(fetch = FetchType.LAZY, orphanRemoval = true)
private Set<Identity> identities;
@JoinTable(name = "user_roles", joinColumns = {
@JoinColumn(name = "user_id")}, inverseJoinColumns = {
@JoinColumn(name = "role_id")})
@OneToMany(fetch = FetchType.LAZY)
private Set<Role> roles;
Steps:
Execute below query
@Query("SELECT u FROM User u JOIN u.identities i JOIN FETCH u.roles r WHERE i.sub = :sub AND i.issuer = :issuer")
Optional
Actual result in JVM: everything works as expected Actual result in Native: Generation of HibernateProxy instances at runtime is not allowed when the configured BytecodeProvider
Please help.
Thank you
Comment From: mhalbritter
Hello! Do you have the hibernate enhancer plugin in your build, like the generated project from start.spring.io has?
Comment From: denysandriyanov
Hi Moritz. Actually, i did try that but with 3.1.0 version and got there another error related to hibernate with that exact version. But now i tried spring boot 3.0.7 with the suggested plugin and it did fix the problem.
Thank you
Comment From: mhalbritter
Yeah, there's a known issue with Hibernate 6.2 and native-image. This will be fixed with the next native build tools update.