Hi,6
Getting a stackoverflow with hibernate 6.
So I have 2 ManyToOne mappings because now in Hibernate 6 OneToOne does unique constraint.
something like that
OrderEntity--(OneToMany)-->OrderItem--(ManyToOne LAZY)-->Sku--(ManyToOne EAGER)-->Product--(ManyToOne EAGER)-->Sku
|
(ManyToOne LAZY)
|
Product
So I load OrderEntity with em.find and iterate over orderItems (currently I have 1)
now I do
session.get(Sku, orderItem.getSku().getId())
It it goes to infinite recursion and fails with stack overflow.
While debugging I found that session.getPersistnceContext().proxiesByKey contains both sku & product.
If I somehow make product or sku initialized, so it will be in session.getPersistnceContext().entitiesByKey and only one of them will be in the proxiesByKey it will be able to resolve a tree.
If I will mark ManyToOne from Sku to Product as lazy, it will also be able to resolve the entity tree…
So there is somewhere a bug that prevents is not able to identify that it already tried to resolve relationship and it is time to do a real fetch…