eclipse-ee4j / eclipselink

Eclipselink project
https://eclipse.dev/eclipselink/
Other
200 stars 170 forks source link

BatchFetch IN fails to fetch eager reference when selecting non-root entity #2011

Open andilem opened 11 months ago

andilem commented 11 months ago

EclipseLink version 4.0.2

When selecting a non-root entity (e.g. query.select(root.get(child))) and child has a @ManyToOne reference with @BatchFetch(value=IN), the references of the children are not fetched. They are just null, even with fetchType=EAGER.

There is a simple test case attached with

eclipselink-batchfetch-selectnonroot.zip

impacsl commented 9 months ago

We have similar issues with OneToOne-references with three entities using BatchFetchType IN/JOIN/EXISTS:

Record - OneToMany / LAZY - Transaction - OneToOne / BatchFetch - Communication

In some cases the List of Transactions contains Communications that are null.

When removing the @BatchFetch it works as well as expected.

EclipseLink 4.0.2, but also other versions (4.0.1, 2.7.14)