I encountered a bug when performing a join fetch across two relations.
The structure shall reflect a hierarchical tree consisting of Node objects.
Node (name:String, children:List<Node>)
Additionally, there's a second entity that flattens out the tree nodes for quicker access.
NodeRelation (ancestor:Node, descendant:Node, distance:int)
Now, I perform a query that fetches all node relations join fetching the descendant node (its a -to-one relation) and all of its children (to-many). Depending on the data I end up in the situation that the node objects are duplicated in their parents children list.
More details can be found in the attached unit test.
I've successfully tested the same query with two other JPA implementations, so I consider this Hibernate-related.
Hibernate 5.1.0.Final, h2database 1.3.176
The test case uses a bag. When I change it to use a List, it works correctly.