Inconsistent result on case of cascaded join fetching

Description

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.

Environment

Hibernate 5.1.0.Final, h2database 1.3.176

Activity

Show:
Gail Badner
March 17, 2016, 7:15 PM

The test case uses a bag. When I change it to use a List, it works correctly.

Assignee

Unassigned

Reporter

Ingo Kofler

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure