Markus Haarländer (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63ef997...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjI3YmJhZjBj...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16197?atlOrigin=eyJpIjoiMjI3Ym...
) HHH-16197 (
https://hibernate.atlassian.net/browse/HHH-16197?atlOrigin=eyJpIjoiMjI3Ym...
) Circular References of the same entity result in different Java Objects when caching
enabled and using a query (
https://hibernate.atlassian.net/browse/HHH-16197?atlOrigin=eyJpIjoiMjI3Ym...
)
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Components: hibernate-jcache
Created: 17/Feb/2023 09:19 AM Priority: Major Reporter: Markus Haarländer (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63ef997...
)
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.)
If you set "hibernate.cache.use_second_level_cache" to false, everything works
fine
Thank you for any help.
(
https://hibernate.atlassian.net/browse/HHH-16197#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16197#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100216- sha1:3fa9804 )