diff --git a/src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java b/src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java index c1a59fb7a..3b9c79453 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java @@ -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 extends SimpleJpaRepository implements QueryDslPredicateExecutor { @@ -200,7 +201,19 @@ public class QueryDslJpaRepository 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 hint : metadata.getQueryHints().entrySet()) { + query.setHint(hint.getKey(), hint.getValue()); + } + + return query; } /** diff --git a/src/test/java/org/springframework/data/jpa/repository/EntityGraphRepositoryMethodsIntegrationTests.java b/src/test/java/org/springframework/data/jpa/repository/EntityGraphRepositoryMethodsIntegrationTests.java index e049995d0..5465ebb30 100644 --- a/src/test/java/org/springframework/data/jpa/repository/EntityGraphRepositoryMethodsIntegrationTests.java +++ b/src/test/java/org/springframework/data/jpa/repository/EntityGraphRepositoryMethodsIntegrationTests.java @@ -147,7 +147,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests { } } - @Test // DATAJPA-790 + @Test // DATAJPA-790, DATACMNS-1087 public void shouldRespectConfiguredJpaEntityGraphWithPaginationAndQueryDslPredicates() { Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));