Skip to content

FluentQueryByPredicate does not respect property projection when paging #2477

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

Closed
Rob4001 opened this issue Mar 28, 2022 · 3 comments
Closed
Assignees
Labels
type: bug A general bug

Comments

@Rob4001
Copy link

Rob4001 commented Mar 28, 2022

Currently using:
repo.findBy(predicate, query -> { return query.project("relatedObject").page(pageable); });

Where relatedObject is a lazy xToMany relationship on the entity in the repo.
Once the query is completed I still get lazy fetches for all my entities instead of the graph hint being populated to allow a larger but simpler query.

Is there a reason why the read page query does not apply the following logic ?

https://github.com/spring-projects/spring-data-jpa/blob/main/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/FetchableFluentQueryByPredicate.java#L176-L182
if (!properties.isEmpty()) { pagedQuery.setHint(EntityGraphFactory.HINT, EntityGraphFactory.create(entityManager, entityType, properties)); }

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 28, 2022
@schauder schauder added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 30, 2022
@schauder schauder self-assigned this Mar 30, 2022
@schauder
Copy link
Contributor

Please provide a Minimimal Reproducable Example, preferable as a Github repository. Make sure to include the database, either as an in memory database or if that is not possible using Testcontainers.

@schauder schauder added the status: waiting-for-feedback We need additional information before we can continue label Mar 30, 2022
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Apr 6, 2022
@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants