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

Derived Method Unneccessarily Joins for filter #3423

Open
Tracked by #3588
JLevins189 opened this issue Apr 12, 2024 · 1 comment
Open
Tracked by #3588

Derived Method Unneccessarily Joins for filter #3423

JLevins189 opened this issue Apr 12, 2024 · 1 comment
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@JLevins189
Copy link

As an example let's take the book and author use-case...
In my database I have a author_id foreign key that maps to a book's id column

If these are set to lazy fetch type, we could assume that we should be able to filter by bookId on the author table without needing to join to the book table
For some reason JPA derived methods decide instead of a where clause like so

SELECT a.*
FROM authors a
WHERE a.book_id=?1

it does the following:

SELECT a.*
FROM author a
LEFT JOIN books b on a.book_id=b.id
WHERE b.id=?1

This may make more sense for eagerly fetched entities but can someone help me understand why JPA would do this or if this should be the way it's done?
This is having a noticeable performance impact on larger table joins. Currently using native queries as a workaround although with a huge amount of database tables that is cumbersome and messy.

Thanks

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 12, 2024
@quaff
Copy link
Contributor

quaff commented Apr 15, 2024

It's duplicate of #3349, may be fixed by #3374.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

4 participants