While migrating an existing application to Hibernate 6.x, I noticed that some code was starting to fail with a StackOverflowError. It seems like this is related to the fact that our code uses Hibernate’s natural key loading support in these cases. I’ve created a quite trivial example to reproduce the issue; it uses Spring to bootstrap Hibernate as a JPA provider, but I’m not relying on something like Spring Data JPA in any way. This is all “pure” Hibernate, AFAICT. You can simply run the Spring Boot application to see the problem in action. Here’s a screenshot of the debugger showing the issue: the navigablePath keeps on growing as the bi-directional association is being navigated. 
|