HHH-18291 predicate expression type resolved from expressible java type insted of direct java type
This commit is contained in:
parent
3ee4015fe9
commit
859a945624
|
@ -264,6 +264,7 @@ import static org.hibernate.query.sqm.TemporalUnit.TIMEZONE_HOUR;
|
||||||
import static org.hibernate.query.sqm.TemporalUnit.TIMEZONE_MINUTE;
|
import static org.hibernate.query.sqm.TemporalUnit.TIMEZONE_MINUTE;
|
||||||
import static org.hibernate.query.sqm.TemporalUnit.WEEK_OF_MONTH;
|
import static org.hibernate.query.sqm.TemporalUnit.WEEK_OF_MONTH;
|
||||||
import static org.hibernate.query.sqm.TemporalUnit.WEEK_OF_YEAR;
|
import static org.hibernate.query.sqm.TemporalUnit.WEEK_OF_YEAR;
|
||||||
|
import static org.hibernate.query.sqm.internal.SqmUtil.resolveExpressibleJavaTypeClass;
|
||||||
import static org.hibernate.type.descriptor.DateTimeUtils.DATE_TIME;
|
import static org.hibernate.type.descriptor.DateTimeUtils.DATE_TIME;
|
||||||
import static org.hibernate.type.spi.TypeConfiguration.isJdbcTemporalType;
|
import static org.hibernate.type.spi.TypeConfiguration.isJdbcTemporalType;
|
||||||
|
|
||||||
|
@ -2918,8 +2919,11 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
@Override
|
@Override
|
||||||
public SqmPredicate visitBooleanExpressionPredicate(HqlParser.BooleanExpressionPredicateContext ctx) {
|
public SqmPredicate visitBooleanExpressionPredicate(HqlParser.BooleanExpressionPredicateContext ctx) {
|
||||||
final SqmExpression<?> expression = (SqmExpression<?>) ctx.expression().accept( this );
|
final SqmExpression<?> expression = (SqmExpression<?>) ctx.expression().accept( this );
|
||||||
if ( expression.getJavaType() != Boolean.class ) {
|
if ( resolveExpressibleJavaTypeClass( expression ) != Boolean.class ) {
|
||||||
throw new SemanticException( "Non-boolean expression used in predicate context: " + ctx.getText(), query );
|
throw new SemanticException(
|
||||||
|
"Non-boolean expression used in predicate context: " + ctx.getText(),
|
||||||
|
query
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final SqmExpression<Boolean> booleanExpression = (SqmExpression<Boolean>) expression;
|
final SqmExpression<Boolean> booleanExpression = (SqmExpression<Boolean>) expression;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -43,6 +44,7 @@ import org.hibernate.query.spi.QueryParameterBinding;
|
||||||
import org.hibernate.query.spi.QueryParameterBindings;
|
import org.hibernate.query.spi.QueryParameterBindings;
|
||||||
import org.hibernate.query.spi.QueryParameterImplementor;
|
import org.hibernate.query.spi.QueryParameterImplementor;
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
|
import org.hibernate.query.sqm.SqmExpressible;
|
||||||
import org.hibernate.query.sqm.SqmPathSource;
|
import org.hibernate.query.sqm.SqmPathSource;
|
||||||
import org.hibernate.query.sqm.SqmQuerySource;
|
import org.hibernate.query.sqm.SqmQuerySource;
|
||||||
import org.hibernate.query.sqm.spi.JdbcParameterBySqmParameterAccess;
|
import org.hibernate.query.sqm.spi.JdbcParameterBySqmParameterAccess;
|
||||||
|
@ -753,6 +755,13 @@ public class SqmUtil {
|
||||||
return selection != null && selection.getSelectableNode() instanceof SqmTuple;
|
return selection != null && selection.getSelectableNode() instanceof SqmTuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Class<?> resolveExpressibleJavaTypeClass(final SqmExpression<?> expression) {
|
||||||
|
final SqmExpressible<?> expressible = expression.getExpressible();
|
||||||
|
return expressible == null || expressible.getExpressibleJavaType() == null
|
||||||
|
? null
|
||||||
|
: expressible.getExpressibleJavaType().getJavaTypeClass();
|
||||||
|
}
|
||||||
|
|
||||||
private static class CriteriaParameterCollector {
|
private static class CriteriaParameterCollector {
|
||||||
private Set<SqmParameter<?>> sqmParameters;
|
private Set<SqmParameter<?>> sqmParameters;
|
||||||
private Map<JpaCriteriaParameter<?>, List<SqmJpaCriteriaParameterWrapper<?>>> jpaCriteriaParamResolutions;
|
private Map<JpaCriteriaParameter<?>, List<SqmJpaCriteriaParameterWrapper<?>>> jpaCriteriaParamResolutions;
|
||||||
|
|
Loading…
Reference in New Issue