DATAJPA-1087 - Apply query hints to count queries for Querydsl but leave out fetch graphs.
We now make sure to apply query hints also to count queries created via Querydsl Predicates but avoid applying potential fetch graphs. Please note that for the 1.x line we’ll preserve binary comparability while for 2.x we’ll change the signature of SimpleJpaRepository.getQueryHints(). Original pull request: #195. Related pull request: #196.
This commit is contained in:
committed by
Oliver Gierke
parent
b290ee6fb9
commit
a51de404ba
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2015 the original author or authors.
|
||||
* Copyright 2008-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,6 +46,7 @@ import com.querydsl.jpa.impl.AbstractJPAQuery;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Jocelyn Ntakpe
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class QueryDslJpaRepository<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>
|
||||
implements QueryDslPredicateExecutor<T> {
|
||||
@@ -196,7 +197,19 @@ public class QueryDslJpaRepository<T, ID extends Serializable> extends SimpleJpa
|
||||
* @return the Querydsl count {@link JPQLQuery}.
|
||||
*/
|
||||
protected JPQLQuery<?> createCountQuery(Predicate predicate) {
|
||||
return querydsl.createQuery(path).where(predicate);
|
||||
AbstractJPAQuery<?, ?> query = querydsl.createQuery(path).where(predicate);
|
||||
|
||||
CrudMethodMetadata metadata = getRepositoryMethodMetadata();
|
||||
|
||||
if (metadata == null) {
|
||||
return query;
|
||||
}
|
||||
|
||||
for (Entry<String, Object> hint : metadata.getQueryHints().entrySet()) {
|
||||
query.setHint(hint.getKey(), hint.getValue());
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -160,7 +160,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-790
|
||||
* @see DATAJPA-790, DATAJPA-1087
|
||||
*/
|
||||
@Test
|
||||
public void shouldRespectConfiguredJpaEntityGraphWithPaginationAndQueryDslPredicates() {
|
||||
|
||||
Reference in New Issue
Block a user