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
8bead06c56
commit
79a8d89667
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2016 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.
|
||||
@@ -47,6 +47,7 @@ import com.querydsl.jpa.impl.AbstractJPAQuery;
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
* @author Jocelyn Ntakpe
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class QueryDslJpaRepository<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>
|
||||
implements QueryDslPredicateExecutor<T> {
|
||||
@@ -200,7 +201,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -147,7 +147,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATAJPA-790
|
||||
@Test // DATAJPA-790, DATACMNS-1087
|
||||
public void shouldRespectConfiguredJpaEntityGraphWithPaginationAndQueryDslPredicates() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
|
||||
Reference in New Issue
Block a user