HHH-18709 Use path to infer criteria value-bind parameter type on `set`

This commit is contained in:
Marco Belladelli 2024-11-28 16:32:38 +01:00
parent 2fa1765f5c
commit d433133946
1 changed files with 6 additions and 4 deletions

View File

@ -180,7 +180,9 @@ public class SqmUpdateStatement<T>
@Override
public <Y, X extends Y> SqmUpdateStatement<T> set(Path<Y> attribute, X value) {
applyAssignment( (SqmPath<Y>) attribute, (SqmExpression<? extends Y>) nodeBuilder().value( value ) );
final SqmCriteriaNodeBuilder nodeBuilder = (SqmCriteriaNodeBuilder) nodeBuilder();
final SqmPath<Y> sqmAttribute = (SqmPath<Y>) attribute;
applyAssignment( sqmAttribute, nodeBuilder.value( value, sqmAttribute ) );
return this;
}
@ -192,15 +194,15 @@ public class SqmUpdateStatement<T>
@Override @SuppressWarnings({"rawtypes", "unchecked"})
public SqmUpdateStatement<T> set(String attributeName, Object value) {
final SqmPath sqmPath = getTarget().get(attributeName);
final SqmPath sqmPath = getTarget().get( attributeName );
final SqmExpression expression;
if ( value instanceof SqmExpression ) {
expression = (SqmExpression) value;
}
else {
expression = (SqmExpression) nodeBuilder().value( value );
final SqmCriteriaNodeBuilder nodeBuilder = (SqmCriteriaNodeBuilder) nodeBuilder();
expression = nodeBuilder.value( value, sqmPath );
}
assertAssignable( null, sqmPath, expression, nodeBuilder() );
applyAssignment( sqmPath, expression );
return this;
}