Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andilem opened this issue Nov 29, 2023 · 1 comment
Open

Comments

@andilem
Copy link

andilem commented Nov 29, 2023

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

  • three entity types with unidirectional (eager) many-to-one references (Record -> User -> Company)
  • User -> Company reference has @BatchFetch(value=IN)
  • query.select(query.from(Record.class).get("user"))
  • em.createQuery(query).getResultList() returns users with company = null
  • when removing @BatchFetch(value=IN), everything works as expected

eclipselink-batchfetch-selectnonroot.zip

@impacsl
Copy link

impacsl commented Feb 15, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants