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

Activity

Show:
Guillaume Smet
January 8, 2019, 12:05 AM

Just saw you assigned it to me. Please don't do that because I'm not working on this issue and it prevents others to take a look at it.

Thanks.

Guillaume Smet
January 8, 2019, 12:06 AM

if it worked in 5.2, it looks like a pretty bad regression, could you take a look to check if the test case is legit?

Gail Badner
January 8, 2019, 1:33 PM

After commenting out the following, the test passes:

<property name="hibernate.default_batch_fetch_size">64</property>

Gail Badner
January 8, 2019, 2:26 PM

, I reverted and (HHH-12556 had conflicts) and the test passes.

Let me know if you'd like me to look into it.

Gail Badner
February 19, 2019, 4:53 PM

Fixed in 5.3 branch as well.

Fixed

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