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).
Java 8, Java 10, Spring 5.X
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.
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?
After commenting out the following, the test passes:
<property name="hibernate.default_batch_fetch_size">64</property>
, I reverted and (HHH-12556 had conflicts) and the test passes.
Let me know if you'd like me to look into it.
Fixed in 5.3 branch as well.