diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutor.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutor.java index c16f95c0a..08f3b7ab0 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutor.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutor.java @@ -75,6 +75,12 @@ import com.querydsl.jpa.impl.AbstractJPAQuery; */ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecutor, JpaRepositoryConfigurationAware { + private static final String PREDICATE_MUST_NOT_BE_NULL = "Predicate must not be null"; + private static final String ORDER_SPECIFIERS_MUST_NOT_BE_NULL = "Order specifiers must not be null"; + private static final String SORT_MUST_NOT_BE_NULL = "Sort must not be null"; + private static final String PAGEABLE_MUST_NOT_BE_NULL = "Pageable must not be null"; + private static final String QUERY_FUNCTION_MUST_NOT_BE_NULL = "Query function must not be null"; + private final JpaEntityInformation entityInformation; private final EntityPath path; private final Querydsl querydsl; @@ -116,7 +122,7 @@ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecuto @Override public Optional findOne(Predicate predicate) { - Assert.notNull(predicate, "Predicate must not be null"); + Assert.notNull(predicate, PREDICATE_MUST_NOT_BE_NULL); try { return Optional.ofNullable(createQuery(predicate).select(path).limit(2).fetchOne()); @@ -128,7 +134,7 @@ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecuto @Override public List findAll(Predicate predicate) { - Assert.notNull(predicate, "Predicate must not be null"); + Assert.notNull(predicate, PREDICATE_MUST_NOT_BE_NULL); return createQuery(predicate).select(path).fetch(); } @@ -136,8 +142,8 @@ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecuto @Override public List findAll(Predicate predicate, OrderSpecifier... orders) { - Assert.notNull(predicate, "Predicate must not be null"); - Assert.notNull(orders, "Order specifiers must not be null"); + Assert.notNull(predicate, PREDICATE_MUST_NOT_BE_NULL); + Assert.notNull(orders, ORDER_SPECIFIERS_MUST_NOT_BE_NULL); return executeSorted(createQuery(predicate).select(path), orders); } @@ -145,8 +151,8 @@ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecuto @Override public List findAll(Predicate predicate, Sort sort) { - Assert.notNull(predicate, "Predicate must not be null"); - Assert.notNull(sort, "Sort must not be null"); + Assert.notNull(predicate, PREDICATE_MUST_NOT_BE_NULL); + Assert.notNull(sort, SORT_MUST_NOT_BE_NULL); return executeSorted(createQuery(predicate).select(path), sort); } @@ -154,7 +160,7 @@ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecuto @Override public List findAll(OrderSpecifier... orders) { - Assert.notNull(orders, "Order specifiers must not be null"); + Assert.notNull(orders, ORDER_SPECIFIERS_MUST_NOT_BE_NULL); return executeSorted(createQuery(new Predicate[0]).select(path), orders); } @@ -162,8 +168,8 @@ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecuto @Override public Page findAll(Predicate predicate, Pageable pageable) { - Assert.notNull(predicate, "Predicate must not be null"); - Assert.notNull(pageable, "Pageable must not be null"); + Assert.notNull(predicate, PREDICATE_MUST_NOT_BE_NULL); + Assert.notNull(pageable, PAGEABLE_MUST_NOT_BE_NULL); final JPQLQuery countQuery = createCountQuery(predicate); JPQLQuery query = querydsl.applyPagination(pageable, createQuery(predicate).select(path)); @@ -175,8 +181,8 @@ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecuto @Override public R findBy(Predicate predicate, Function, R> queryFunction) { - Assert.notNull(predicate, "Predicate must not be null"); - Assert.notNull(queryFunction, "Query function must not be null"); + Assert.notNull(predicate, PREDICATE_MUST_NOT_BE_NULL); + Assert.notNull(queryFunction, QUERY_FUNCTION_MUST_NOT_BE_NULL); Function> finder = sort -> { AbstractJPAQuery select = (AbstractJPAQuery) createQuery(predicate).select(path); @@ -260,7 +266,7 @@ public class QuerydslJpaPredicateExecutor implements QuerydslPredicateExecuto */ protected AbstractJPAQuery createQuery(Predicate... predicate) { - Assert.notNull(predicate, "Predicate must not be null"); + Assert.notNull(predicate, PREDICATE_MUST_NOT_BE_NULL); AbstractJPAQuery query = doCreateQuery(getQueryHints().withFetchGraphs(entityManager), predicate); CrudMethodMetadata metadata = getRepositoryMethodMetadata();