Hibernate seems to have an issue under the following scenario (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).
However, this issue does not seem to occur in 5.4.15 (only in 5.3.17) while the above issue does occur in both. |
|