Markus Haarländer (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63ef997...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODAxMTMyOWFh...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16197?atlOrigin=eyJpIjoiODAxMT...
) HHH-16197 (
https://hibernate.atlassian.net/browse/HHH-16197?atlOrigin=eyJpIjoiODAxMT...
) 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=eyJpIjoiODAxMT...
)
Change By: 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. 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.
(
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#100217- sha1:d96fecc )