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 25a91f8ce..40a6d35c3 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-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 extends SimpleJpaRepository implements QueryDslPredicateExecutor { @@ -196,7 +197,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 33a84f3b1..f8b59203d 100644 --- a/src/test/java/org/springframework/data/jpa/repository/EntityGraphRepositoryMethodsIntegrationTests.java +++ b/src/test/java/org/springframework/data/jpa/repository/EntityGraphRepositoryMethodsIntegrationTests.java @@ -160,7 +160,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests { } /** - * @see DATAJPA-790 + * @see DATAJPA-790, DATAJPA-1087 */ @Test public void shouldRespectConfiguredJpaEntityGraphWithPaginationAndQueryDslPredicates() {