Closed ftsuda-senac closed 2 years ago
This doesn't seem to be a Spring Data, but a Hibernate issue.
I created a PR to your demonstrator demonstrating it. You'll need to create an issue with Hibernate.
Make sure to create a reproducer that does not use Spring, since understandably they don't appreciate to deal with other frameworks when debugging issues.
I'd appreciate it if you could leave a link here to the Hibernate issue, so others can find it more easily.
@schauder Thanks for reply. Opened the issue https://hibernate.atlassian.net/browse/HHH-15307 and updated the demo to a pure Hibernate application,
I stopped seeing this error after upgrading to 6.2.6.Final.
I had the same error in the version 6.4.4.Final and I notice that is a ClassLoader Issue between Hibernate and Spring Dev Tools.
First, I have this code
And this the SessionFactory
And this is the Entity
This is the Properties
hibernate.connection.url=jdbc:h2:mem:bookingdb hibernate.connection.username=sa hibernate.connection.password=sa hibernate.show_sql=true hibernate.format_sql=true hibernate.highlight_sql=true hibernate.hbm2ddl.auto=create
In the pom.xml I have the Spring DEV TOOLS
When I run the App i get A similar error
When I debug the App searching the exception I noticed that the Futbolistas object classLoader Is different that Hibernate Field classLoader. Field is generated from Hibernate with the AppClassLoader. The exception is throwed from this code fragment in the line 58.
The Futbolistas Class was generated with the dev tool classLoader
Reading the dev tool docs I found this
When I drop the devtools dependency in the pom, making a mvn install, hopefully the app works fine :)
So, in my case, the solution was drop the dev tools.
After Spring Boot migration from 2.5.14 to 2.6 (or 2.7), this error started to show when i try to save some related entities to database:
Since i'm using a quite complex Entity mapping configuration that involves inheritance and multi-column Primary Keys with EmbeddedId, i've wrote a small application in order to reproduce this error. The application can be found at https://github.com/ftsuda-senac/data-jpa-error
Steps to reproduce the error:
After downloading the application mentioned above, run as
mvn test
A successful test can be achieved changing the Spring Boot version to 2.5.14 and running the same command
mvn test