Upgrade to Hibernate 5.2.5 and fixes

https://build.spring.io/browse/INT-FATS5IC-22/

Since some version after Hibernate 5.1 they support positional parameters in the `Query` starting from `0` index, therefore we don't need `-1` logic in the `DefaultJpaOperations` any more.
Also fix typos
This commit is contained in:
Artem Bilan
2016-12-19 10:53:59 -05:00
parent 968812c90b
commit f59aaed338
3 changed files with 14 additions and 13 deletions

View File

@@ -94,7 +94,7 @@ subprojects { subproject ->
guavaVersion = '19.0'
hamcrestVersion = '1.3'
hazelcastVersion = '3.6.1'
hibernateVersion = '5.1.0.Final'
hibernateVersion = '5.2.5.Final'
hsqldbVersion = '2.3.3'
h2Version = '1.4.180'
jackson2Version = '2.7.3'

View File

@@ -39,9 +39,9 @@ import org.springframework.util.StringUtils;
*
* @author Amol Nayak
* @author Gunnar Hillert
* @author Artem Bilan
*
* @since 2.2
*
*/
public class DefaultJpaOperations extends AbstractJpaOperations {
@@ -307,7 +307,7 @@ public class DefaultJpaOperations extends AbstractJpaOperations {
if (position != null) {
if (source instanceof PositionSupportingParameterSource) {
paramValue = ((PositionSupportingParameterSource) source).getValueByPosition(position - 1);
paramValue = ((PositionSupportingParameterSource) source).getValueByPosition(position);
query.setParameter(position, paramValue);
}
else {
@@ -325,7 +325,7 @@ public class DefaultJpaOperations extends AbstractJpaOperations {
else {
throw new JpaOperationFailedException(
"This parameter does not contain a parameter name. " +
"Additionally it is not a postitional parameter, neither.", queryString);
"Additionally it is not a positional parameter, neither.", queryString);
}
}

View File

@@ -33,12 +33,13 @@ import org.springframework.integration.jpa.support.parametersource.ExpressionEva
import org.springframework.util.Assert;
/**
* A SpEL expression based {@link ParameterSourceFactory} implementation.
*
* @author Gunnar Hillert
* @author Gary Russell
* @author Artem Bilan
* @since 2.2
*
* @since 2.2
*/
public class ExpressionEvaluatingParameterSourceFactory implements ParameterSourceFactory {
@@ -55,13 +56,12 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
}
public ExpressionEvaluatingParameterSourceFactory(BeanFactory beanFactory) {
this.parameters = new ArrayList<JpaParameter>();
this.parameters = new ArrayList<>();
this.expressionEvaluator.setBeanFactory(beanFactory);
}
/**
* Define the (optional) parameter values.
*
* @param parameters the parameters to be set
*/
public void setParameters(List<JpaParameter> parameters) {
@@ -83,11 +83,11 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
}
class ExpressionEvaluatingParameterSource implements PositionSupportingParameterSource {
protected class ExpressionEvaluatingParameterSource implements PositionSupportingParameterSource {
private final Object input;
private volatile Map<String, Object> values = new HashMap<String, Object>();
private volatile Map<String, Object> values = new HashMap<>();
private final List<JpaParameter> parameters;
@@ -95,12 +95,13 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
private final ParameterExpressionEvaluator expressionEvaluator;
ExpressionEvaluatingParameterSource(Object input, List<JpaParameter> parameters, ParameterExpressionEvaluator expressionEvaluator) {
protected ExpressionEvaluatingParameterSource(Object input, List<JpaParameter> parameters,
ParameterExpressionEvaluator expressionEvaluator) {
this.input = input;
this.expressionEvaluator = expressionEvaluator;
this.parameters = parameters;
this.parametersMap = new HashMap<String, JpaParameter>(parameters.size());
this.parametersMap = new HashMap<>(parameters.size());
for (JpaParameter parameter : parameters) {
this.parametersMap.put(parameter.getName(), parameter);
}
@@ -110,7 +111,7 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
public Object getValueByPosition(int position) {
Assert.isTrue(position >= 0, "The position must be be non-negative.");
Assert.isTrue(position >= 0, "The position must be non-negative.");
if (position <= this.parameters.size()) {
@@ -160,7 +161,7 @@ public class ExpressionEvaluatingParameterSourceFactory implements ParameterSour
JpaParameter jpaParameter = this.parametersMap.get(paramName);
Expression expression = null;
Expression expression;
if (this.input instanceof Collection<?>) {
expression = jpaParameter.getProjectionExpression();