Skip to content

Commit

Permalink
[Blazebit#617] Omit the sort param during count query creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Lovato committed Aug 1, 2018
1 parent 23a6756 commit eeef069
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public Query doCreateQuery(Object[] values) {
}

@Override
@SuppressWarnings("unchecked")
public TypedQuery<Long> doCreateCountQuery(Object[] values) {
throw new UnsupportedOperationException();
}
Expand Down Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private JpaParameters(List<JpaParameter> parameters) {
super(parameters);
}

/* *
/**
* Gets the parameters annotated with {@link OptionalParam}.
*
* @return the optional parameters
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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}.
Expand Down

0 comments on commit eeef069

Please sign in to comment.