From 8155b6bcdaea9a1cd8be146eb2a0ed9c1e91ca97 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Fri, 1 Sep 2023 11:24:23 +0200 Subject: [PATCH] HHH-17135 Fix entity-typed null-literal --- .../org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java index 0ccd9461e6..489e162336 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java @@ -5298,6 +5298,10 @@ public abstract class BaseSqmToSqlAstConverter extends Base if ( mappingModelExpressible instanceof BasicValuedMapping ) { return new QueryLiteral<>( null, (BasicValuedMapping) mappingModelExpressible ); } + else if ( mappingModelExpressible instanceof EntityMappingType ) { + // When selecting a literal null entity type, we should simply return a single null object + mappingModelExpressible = null; + } final MappingModelExpressible keyExpressible = getKeyExpressible( mappingModelExpressible ); if ( keyExpressible == null ) { // treat Void as the bottom type, the class of null