diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/QueryParameters.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/QueryParameters.java index 36bbb2e116..a942be7c1f 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/QueryParameters.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/QueryParameters.java @@ -70,7 +70,7 @@ public final class QueryParameters { private String processedSQL; private Type[] processedPositionalParameterTypes; private Object[] processedPositionalParameterValues; - + private HQLQueryPlan queryPlan; public QueryParameters() { @@ -91,7 +91,6 @@ public final class QueryParameters { this.optionalObject = optionalObject; this.optionalId = optionalObjectId; this.optionalEntityName = optionalEntityName; - } public QueryParameters( @@ -665,4 +664,20 @@ public final class QueryParameters { public void setQueryPlan(HQLQueryPlan queryPlan) { this.queryPlan = queryPlan; } + + public void bindDynamicParameter(Type paramType, Object paramValue) { + if(processedPositionalParameterTypes != null) { + int length = processedPositionalParameterTypes.length; + Type[] types = new Type[length + 1]; + Object[] values = new Object[length + 1]; + for ( int i = 0; i < length; i++ ) { + types[i] = processedPositionalParameterTypes[i]; + values[i] = processedPositionalParameterValues[i]; + } + types[length] = paramType; + values[length] = paramValue; + processedPositionalParameterTypes = types; + processedPositionalParameterValues = values; + } + } } diff --git a/hibernate-core/src/main/java/org/hibernate/param/DynamicFilterParameterSpecification.java b/hibernate-core/src/main/java/org/hibernate/param/DynamicFilterParameterSpecification.java index 916d45efd3..def45bdf99 100644 --- a/hibernate-core/src/main/java/org/hibernate/param/DynamicFilterParameterSpecification.java +++ b/hibernate-core/src/main/java/org/hibernate/param/DynamicFilterParameterSpecification.java @@ -50,17 +50,22 @@ public class DynamicFilterParameterSpecification implements ParameterSpecificati SharedSessionContractImplementor session, int start) throws SQLException { final int columnSpan = definedParameterType.getColumnSpan( session.getFactory() ); - final Object value = session.getLoadQueryInfluencers().getFilterParameterValue( filterName + '.' + parameterName ); + final String fullParamName = filterName + '.' + parameterName; + final Object value = session.getLoadQueryInfluencers().getFilterParameterValue(fullParamName); + final Type type = session.getLoadQueryInfluencers().getFilterParameterType(fullParamName); if ( Collection.class.isInstance( value ) ) { int positions = 0; Iterator itr = ( ( Collection ) value ).iterator(); while ( itr.hasNext() ) { - definedParameterType.nullSafeSet( statement, itr.next(), start + positions, session ); + Object next = itr.next(); + qp.bindDynamicParameter( type, next ); + definedParameterType.nullSafeSet( statement, next, start + positions, session ); positions += columnSpan; } return positions; } else { + qp.bindDynamicParameter(type, value); definedParameterType.nullSafeSet( statement, value, start, session ); return columnSpan; }