OneToMany with referencedColumnName returns too many entities

Description

There seems to be a regression in 5.3.X from previous versions when using a OneToMany relation with referencedColumnName and EAGER fetching (it does not happen with LAZY fetching).

When fetching a parent instance with one or many children, Hibernate returns a random number of entities.

Parent:

Child:

When adding 2 children and 1 parent to the database, we end up with a List of 26 children in the parent.

This is fairly old code and could be done much better but with any version lower than 5.3.X it works fine.

This has been tested with Postgresql, Oracle and H2 (in memory) and is always reproducible.

I have attached a test (maven setup).

Environment

Java 8, Java 10, Spring 5.X

Assignee

Guillaume Smet

Reporter

Michel Zimmermann

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.17

Components

Priority

Critical
Configure