We switched from Hibernate 5 to 6 and observed a strange behaviour:
hibernate 6.1.7 hibernate-jcache 6.1.7 ehcache 3.10.8
Model with a circular reference: Child(id=c1) -> Parent (id=p1) -> Child(id=c1)
When using an EntityManager to find the Child with id=c1, everything is fine. Child result = entityManager.find(Child.class, "c1"); The returned result is the same object as the one in result.getParent().getChild().
However, when using a simple query like: Child result = entityManager.createQuery("SELECT child from Child child WHERE child.objectId = 'c1'", Child.class).getSingleResult(); The returned result is a different Java Object than the one in result.getParent().getChild()
This leads to huge problems.
Please find a testcase here: [ https://github.com/haarli/hibernate-orm-6 |https://github.com/haarli/hibernate-orm-6] (However, in this test case environment it is not even possible to execute the Query, although it's correct. so there might be an additional bug here. )
If you set "hibernate.cache.use_second_level_cache" to false, everything works fine
Thank you for any help.
|
|