From 96c4b9803901d9ee2a56dbd63ee595b31668fd4e Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Wed, 28 Jun 2023 12:55:47 +0200 Subject: [PATCH] HHH-16803 Specially handle enum classes in nullLiteral --- .../query/sqm/internal/SqmCriteriaNodeBuilder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java index 39995d76a8..88924a6d33 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java @@ -1294,8 +1294,12 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext, @Override public SqmExpression nullLiteral(Class resultClass) { - final TypeConfiguration typeConfiguration = getTypeConfiguration(); - final BasicType basicTypeForJavaType = typeConfiguration.getBasicTypeForJavaType( resultClass ); + if ( resultClass.isEnum() ) { + // No basic types are registered for enum java types, we have to use an untyped null literal in this case + return new SqmLiteralNull<>( this ); + } + final BasicType basicTypeForJavaType = getTypeConfiguration().getBasicTypeForJavaType( resultClass ); + // if there's no basic type, it might be an entity type final SqmExpressible sqmExpressible = basicTypeForJavaType == null ? getDomainModel().managedType( resultClass ) : basicTypeForJavaType;