From cff5d89398d1259547b037d3b93b5d3e4bd77921 Mon Sep 17 00:00:00 2001 From: namucy Date: Thu, 18 Dec 2025 03:19:10 +0900 Subject: [PATCH] HHH-19974 Refactor InformixDialect to override the new getSelectClauseNullString signature. Instead of relying on columnDefinition logic, this change utilizes the DdlTypeRegistry to dynamically determine the correct cast type name, ensuring better compatibility and correctness for null handling in select clauses on Informix. Signed-off-by: namucy --- .../community/dialect/InformixDialect.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java index 00743146139d..139b5eed73ca 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java @@ -40,6 +40,8 @@ import org.hibernate.exception.LockAcquisitionException; import org.hibernate.exception.spi.SQLExceptionConversionDelegate; import org.hibernate.mapping.CheckConstraint; +import org.hibernate.metamodel.mapping.SqlExpressible; +import org.hibernate.metamodel.mapping.SqlTypedMapping; import org.hibernate.query.sqm.CastType; import org.hibernate.query.sqm.IntervalType; import org.hibernate.query.sqm.function.SqmFunctionRegistry; @@ -1097,6 +1099,17 @@ public String getSelectClauseNullString(int sqlType, TypeConfiguration typeConfi return "cast(null as " + castType + ")"; } + // Add override for the newer signature to access columnDefinition + @Override + public String getSelectClauseNullString(SqlTypedMapping sqlType, TypeConfiguration typeConfiguration) { + final DdlTypeRegistry ddlTypeRegistry = typeConfiguration.getDdlTypeRegistry(); + final String castTypeName = ddlTypeRegistry + .getDescriptor( sqlType.getJdbcMapping().getJdbcType().getDdlTypeCode() ) + .getCastTypeName( sqlType.toSize(), (SqlExpressible) sqlType.getJdbcMapping(), ddlTypeRegistry ); + return "cast(null as " + castTypeName + ")"; + } + + private static String castType(DdlType descriptor) { final String typeName = descriptor.getTypeName( Size.length( Size.DEFAULT_LENGTH ) ); //trim off the length/precision/scale