HHH-10893 - Fix Reusing Query but changing collection parameters returns wrong result

This commit is contained in:
Andrea Boriero 2016-06-27 16:03:41 +02:00
parent 0e0f497c2a
commit 5cb5b68f9c
3 changed files with 37 additions and 3 deletions

View File

@ -81,4 +81,22 @@ public class NamedParameterDescriptor implements QueryParameter {
public Type getType() {
return expectedType;
}
@Override
public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
return false;
}
NamedParameterDescriptor that = (NamedParameterDescriptor) o;
return getName().equals( that.getName() );
}
@Override
public int hashCode() {
return getName().hashCode();
}
}

View File

@ -586,9 +586,7 @@ public class QueryParameterBindingsImpl implements QueryParameterBindings {
);
final QueryParameterBinding syntheticBinding = makeBinding( entry.getValue().getBindType() );
syntheticBinding.setBindValue( bindValue );
if ( parameterBindingMap.put( syntheticParam, syntheticBinding ) != null ) {
throw new HibernateException( "Repeated usage of synthetic parameter name [" + syntheticName + "] while expanding list parameter." );
}
parameterBindingMap.put( syntheticParam, syntheticBinding );
i++;
}

View File

@ -49,4 +49,22 @@ public class QueryParameterNamedImpl<T> extends QueryParameterImpl<T> implements
public boolean isJpaPositionalParameter() {
return jpaStyle;
}
@Override
public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
return false;
}
QueryParameterNamedImpl<?> that = (QueryParameterNamedImpl<?>) o;
return getName().equals( that.getName() );
}
@Override
public int hashCode() {
return getName().hashCode();
}
}