[hibernate-issues] [JIRA] (HHH-14008) "Found shared references to collection" exception thrown due to issue with batch fetching duplicating locked entities on refresh

Caspian Borison (JIRA) jira at hibernate.atlassian.net
Sat May 9 01:52:14 EDT 2020


Caspian Borison ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Abead8085-c796-4d7d-9fa0-0ec2008c7f92 ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYzUyZGFmZjE0NWQ0NGE5ZWFjZDk5YThkYjAwZWM2MzMiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14008?atlOrigin=eyJpIjoiYzUyZGFmZjE0NWQ0NGE5ZWFjZDk5YThkYjAwZWM2MzMiLCJwIjoiaiJ9 ) HHH-14008 ( https://hibernate.atlassian.net/browse/HHH-14008?atlOrigin=eyJpIjoiYzUyZGFmZjE0NWQ0NGE5ZWFjZDk5YThkYjAwZWM2MzMiLCJwIjoiaiJ9 ) "Found shared references to collection" exception thrown due to issue with batch fetching duplicating locked entities on refresh ( https://hibernate.atlassian.net/browse/HHH-14008?atlOrigin=eyJpIjoiYzUyZGFmZjE0NWQ0NGE5ZWFjZDk5YThkYjAwZWM2MzMiLCJwIjoiaiJ9 )

Change By: Caspian Borison ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Abead8085-c796-4d7d-9fa0-0ec2008c7f92 )

Hibernate seems to have an issue under the following scenario with the following simple mappings ( all lazy assuming these mappings ) :

* Parent -> OneToMany -> Child
* Child -> ManyToOne -> Parent

# Enable batch fetching
# Read in Parent1 and a (non-related) Child
# Lock and refresh the original Parent1 / this will prompt a batch fetch of the other child's ParentX
## At this time, it appears the original Parent1 is "duplicated" in the session cache
# Directly read in a Child associated with Parent1
# Refresh the original reference to Parent1 causing Hibernate to now directly see two Parent1s in the cache
# Flush the session

Test cases have been attached and can also be retrieved from GitHub:  [https://github.com/caspianb/HibernateRefreshTest/tree/HHH-14008|https://github.com/caspianb/HibernateRefreshTest/tree/HHH-14008|smart-link]

Note I believe this issue is also related to:
[HHH-12268] (which still exists in the latest 5.x versions).

( https://hibernate.atlassian.net/browse/HHH-14008#add-comment?atlOrigin=eyJpIjoiYzUyZGFmZjE0NWQ0NGE5ZWFjZDk5YThkYjAwZWM2MzMiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14008#add-comment?atlOrigin=eyJpIjoiYzUyZGFmZjE0NWQ0NGE5ZWFjZDk5YThkYjAwZWM2MzMiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100126- sha1:9bc00fe )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200509/273e8bc8/attachment.html 


More information about the hibernate-issues mailing list