Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#617] Omit the sort param during count query creation #618

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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