HHH-10870 - Fix Parameter lookup for Iterable fails on Criteria API

This commit is contained in:
Andrea Boriero 2016-06-20 17:07:33 +02:00
parent c8acf1ed9e
commit aa6ab6d074
2 changed files with 6 additions and 27 deletions

View File

@ -584,8 +584,7 @@ public class CriteriaBuilderImpl implements HibernateCriteriaBuilder, Serializab
public <T> ParameterExpression<T> parameter(Class<T> paramClass) { public <T> ParameterExpression<T> parameter(Class<T> paramClass) {
return new ParameterExpressionImpl<T>( return new ParameterExpressionImpl<T>(
this, this,
paramClass, paramClass
sessionFactory.resolveParameterBindType( paramClass )
); );
} }
@ -594,8 +593,7 @@ public class CriteriaBuilderImpl implements HibernateCriteriaBuilder, Serializab
return new ParameterExpressionImpl<T>( return new ParameterExpressionImpl<T>(
this, this,
paramClass, paramClass,
name, name
sessionFactory.resolveParameterBindType( paramClass )
); );
} }

View File

@ -9,12 +9,10 @@ package org.hibernate.query.criteria.internal.expression;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.criteria.ParameterExpression; import javax.persistence.criteria.ParameterExpression;
import org.hibernate.query.QueryParameter;
import org.hibernate.query.criteria.internal.CriteriaBuilderImpl; import org.hibernate.query.criteria.internal.CriteriaBuilderImpl;
import org.hibernate.query.criteria.internal.ParameterRegistry; import org.hibernate.query.criteria.internal.ParameterRegistry;
import org.hibernate.query.criteria.internal.compile.ExplicitParameterInfo; import org.hibernate.query.criteria.internal.compile.ExplicitParameterInfo;
import org.hibernate.query.criteria.internal.compile.RenderingContext; import org.hibernate.query.criteria.internal.compile.RenderingContext;
import org.hibernate.type.Type;
/** /**
* Defines a parameter specification, or the information about a parameter (where it occurs, what is * Defines a parameter specification, or the information about a parameter (where it occurs, what is
@ -24,41 +22,34 @@ import org.hibernate.type.Type;
*/ */
public class ParameterExpressionImpl<T> public class ParameterExpressionImpl<T>
extends ExpressionImpl<T> extends ExpressionImpl<T>
implements ParameterExpression<T>, QueryParameter<T>, Serializable { implements ParameterExpression<T>, Serializable {
private final String name; private final String name;
private final Integer position; private final Integer position;
private final Type expectedType;
public ParameterExpressionImpl( public ParameterExpressionImpl(
CriteriaBuilderImpl criteriaBuilder, CriteriaBuilderImpl criteriaBuilder,
Class<T> javaType, Class<T> javaType,
String name, String name) {
Type expectedType) {
super( criteriaBuilder, javaType ); super( criteriaBuilder, javaType );
this.name = name; this.name = name;
this.position = null; this.position = null;
this.expectedType = expectedType;
} }
public ParameterExpressionImpl( public ParameterExpressionImpl(
CriteriaBuilderImpl criteriaBuilder, CriteriaBuilderImpl criteriaBuilder,
Class<T> javaType, Class<T> javaType,
Integer position, Integer position) {
Type expectedType) {
super( criteriaBuilder, javaType ); super( criteriaBuilder, javaType );
this.name = null; this.name = null;
this.position = position; this.position = position;
this.expectedType = expectedType;
} }
public ParameterExpressionImpl( public ParameterExpressionImpl(
CriteriaBuilderImpl criteriaBuilder, CriteriaBuilderImpl criteriaBuilder,
Class<T> javaType, Class<T> javaType) {
Type expectedType) {
super( criteriaBuilder, javaType ); super( criteriaBuilder, javaType );
this.name = null; this.name = null;
this.position = null; this.position = null;
this.expectedType = expectedType;
} }
public String getName() { public String getName() {
@ -85,14 +76,4 @@ public class ParameterExpressionImpl<T>
public String renderProjection(RenderingContext renderingContext) { public String renderProjection(RenderingContext renderingContext) {
return render( renderingContext ); return render( renderingContext );
} }
@Override
public Type getType() {
return expectedType;
}
@Override
public boolean isJpaPositionalParameter() {
return true;
}
} }