spring-projects / spring-projects/spring-data-jpa

SimpleJpaRepository.findAllById doesn't join eager fetched columns [DATAJPA-1721]

Open
#2,016 1 comment 0 reactions 1 assignee View on GitHub

@schauder is already working on this.

Since Dec 30, 2020.

in: core type: enhancement
Dominant language
Java
Stars
3.3k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

cda opened DATAJPA-1721 and commented

Using SimpleJpaRepository.findById(ID is) results in a query with left outer joins for each eager relationship.

Using SimpleJpaRepository.findAllById(Iterable ids) results in a query that fetches current entity columns and additional select queries for each eager relationship.

The performance of findAllById is affected by the additional select queries. Ideally it should generate the same query as findById but with id in () instead of id = .

 
SimpleJpaRepository.findAllById(Iterable ids) is generating a JPQL query to fetch entities and reading Vlad Mihalcea article it seems that using JPQL to fetch entities uses a different fetching strategy than entitymanager.find that results in additional selects


No further details from DATAJPA-1721

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.