-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
FetchableFluentQueryByPredicate does not respect project() call on queryFunction #2820
Comments
Almost a duplicate of #2721 which is basically the same issue for |
At a glance, it appears that private AbstractJPAQuery<?, ?> createSortedAndProjectedQuery() {
AbstractJPAQuery<?, ?> query = finder.apply(sort);
if (!properties.isEmpty()) {
query.setHint(EntityGraphFactory.HINT, EntityGraphFactory.create(entityManager, entityType, properties));
}
return query;
} Here you can see the query hint being applied. However, private Page<R> readPage(Pageable pageable) {
AbstractJPAQuery<?, ?> pagedQuery = pagedFinder.apply(sort, pageable);
List<R> paginatedResults = convert(pagedQuery.fetch());
return PageableExecutionUtils.getPage(paginatedResults, pageable, () -> countOperation.apply(predicate));
} Now I looked at I took a first cut at adding this missing clause to the Without the hints:
WITH the hints:
I'm not sure I can see the hints being applied, but this may simply be an issue with logging. |
I had done the same in my project by creating a custom RepositoryFactoryBean and replacing a few components, and the fetching works like it for I think the issue is with the logging. |
…icate. When using Querydsl predicates to build a fluent query, be sure to apply the projection hint that generates a fetch graph. Resolves #2820.
When using Querydsl predicates to build a fluent query, be sure to apply the projection hint that generates a fetch graph. Resolves #2820.
When calling a
findBy()
method that takes a QuerydslPredicate
and aqueryFunction
, when you pass in the properties you want to fetch using the entity graph and then callpage()
, yourproject()
call is ignored because no query hints are set on the query in theFetchableFluentQueryByPredicate
implementation.The implementation of methods like
all()
inFetchableFluentQueryByPredicate
construct an EntityGraph and set it as a query hint to the JPA query, but this does not happen for thepage()
method.Is there a reason why calls to
project()
are not respected when callingpage()
, or is this a bug?And if there is a reason, maybe this should be indicated in the documentation of the methods or an exception should be thrown?
Please note a similar issue was opened before but was closed due to a lack of minimal working example: #2477
Here is a link to a working minimal example:
https://github.com/MahmoudFawzyKhalil/spring-data-jpa-paged-projection-issue/blob/master/src/main/java/com/example/SpringDataJpaPagedProjectionIssueApplication.java
The text was updated successfully, but these errors were encountered: