From eeef0696a5f1f9678ad6cdab2adbee052a9f61dc Mon Sep 17 00:00:00 2001 From: Giovanni Lovato Date: Wed, 1 Aug 2018 12:24:00 +0200 Subject: [PATCH] [#617] Omit the sort param during count query creation --- ...AbstractPartTreeBlazePersistenceQuery.java | 3 +- .../spring/data/base/query/JpaParameters.java | 58 ++++++++++--------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/integration/spring-data/base/src/main/java/com/blazebit/persistence/spring/data/base/query/AbstractPartTreeBlazePersistenceQuery.java b/integration/spring-data/base/src/main/java/com/blazebit/persistence/spring/data/base/query/AbstractPartTreeBlazePersistenceQuery.java index ca9ff43c0a..2ae73e3609 100644 --- a/integration/spring-data/base/src/main/java/com/blazebit/persistence/spring/data/base/query/AbstractPartTreeBlazePersistenceQuery.java +++ b/integration/spring-data/base/src/main/java/com/blazebit/persistence/spring/data/base/query/AbstractPartTreeBlazePersistenceQuery.java @@ -93,7 +93,6 @@ public Query doCreateQuery(Object[] values) { } @Override - @SuppressWarnings("unchecked") public TypedQuery doCreateCountQuery(Object[] values) { throw new UnsupportedOperationException(); } @@ -432,7 +431,7 @@ protected TypedQuery createQuery0(CriteriaQuery criteriaQuery, Object[] va @Override protected CriteriaQuery invokeQueryCreator(FixedJpaQueryCreator creator, Sort sort) { - return creator.createQuery(sort); + return creator.createQuery(); } } } diff --git a/integration/spring-data/base/src/main/java/com/blazebit/persistence/spring/data/base/query/JpaParameters.java b/integration/spring-data/base/src/main/java/com/blazebit/persistence/spring/data/base/query/JpaParameters.java index a711aabad5..68a2651a0a 100644 --- a/integration/spring-data/base/src/main/java/com/blazebit/persistence/spring/data/base/query/JpaParameters.java +++ b/integration/spring-data/base/src/main/java/com/blazebit/persistence/spring/data/base/query/JpaParameters.java @@ -53,7 +53,7 @@ private JpaParameters(List parameters) { super(parameters); } - /* * + /** * Gets the parameters annotated with {@link OptionalParam}. * * @return the optional parameters @@ -72,13 +72,13 @@ public JpaParameters getOptionalParameters() { } /* - * (non-Javadoc) - * @see org.springframework.data.repository.query.Parameters#createParameter(org.springframework.core.MethodParameter) - */ - @Override - protected JpaParameter createParameter(MethodParameter parameter) { - return new JpaParameter(parameter); - } + * (non-Javadoc) + * @see org.springframework.data.repository.query.Parameters#createParameter(org.springframework.core.MethodParameter) + */ + @Override + protected JpaParameter createParameter(MethodParameter parameter) { + return new JpaParameter(parameter); + } /* * (non-Javadoc) @@ -111,22 +111,24 @@ static class JpaParameter extends Parameter { super(parameter); - this.parameter = parameter; - this.optional = parameter.getParameterAnnotation(OptionalParam.class);this.annotation = parameter.getParameterAnnotation(Temporal.class); - this.temporalType = null; + this.parameter = parameter; + this.optional = parameter.getParameterAnnotation(OptionalParam.class); + this.annotation = parameter.getParameterAnnotation(Temporal.class); + this.temporalType = null; - if (!isDateParameter() && hasTemporalParamAnnotation()) { - throw new IllegalArgumentException( - Temporal.class.getSimpleName() + " annotation is only allowed on Date parameter!"); - } - } + if (!isDateParameter() && hasTemporalParamAnnotation()) { + throw new IllegalArgumentException( + Temporal.class.getSimpleName() + " annotation is only allowed on Date parameter!"); + } + } - public String getParameterName() { - Param annotation = parameter.getParameterAnnotation(Param.class); - if (annotation != null) {return annotation.value(); + public String getParameterName() { + Param annotation = parameter.getParameterAnnotation(Param.class); + if (annotation != null) { + return annotation.value(); } return optional == null ? parameter.getParameterName() : optional.value(); - } + } /* * (non-Javadoc) @@ -137,19 +139,21 @@ public boolean isBindable() { return super.isBindable() || isTemporalParameter(); } - @Override + @Override public boolean isSpecialParameter() { return super.isSpecialParameter() || isOptionalParameter(); } boolean isOptionalParameter() { return optional != null; - }/** - * @return {@literal true} if this parameter is of type {@link Date} and has an {@link Temporal} annotation. - */ - boolean isTemporalParameter() { - return isDateParameter() && hasTemporalParamAnnotation(); - } + } + + /** + * @return {@literal true} if this parameter is of type {@link Date} and has an {@link Temporal} annotation. + */ + boolean isTemporalParameter() { + return isDateParameter() && hasTemporalParamAnnotation(); + } /** * @return the {@link TemporalType} on the {@link Temporal} annotation of the given {@link Parameter}.