HHH-18439 Account for null values in query cache hit

Also, solve an assertion error in query result type check when selecting `null` literals
This commit is contained in:
Marco Belladelli 2024-08-06 08:55:04 +02:00
parent 4bf11f8503
commit a784ca2027
2 changed files with 9 additions and 6 deletions

View File

@ -1094,7 +1094,10 @@ public class SqmUtil {
}
final JavaType<?> selectionExpressibleJavaType = selectionExpressible.getExpressibleJavaType();
assert selectionExpressibleJavaType != null;
if ( selectionExpressibleJavaType == null ) {
// nothing we can validate
return;
}
final Class<?> selectionExpressibleJavaTypeClass = selectionExpressibleJavaType.getJavaTypeClass();
if ( selectionExpressibleJavaTypeClass != Object.class ) {
@ -1103,7 +1106,7 @@ public class SqmUtil {
return;
}
if ( selectionExpressibleJavaType instanceof PrimitiveJavaType<?> primitiveJavaType ) {
if ( selectionExpressibleJavaType instanceof final PrimitiveJavaType<?> primitiveJavaType ) {
if ( primitiveJavaType.getPrimitiveClass() == resultClass ) {
return;
}

View File

@ -176,12 +176,12 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
if ( valueIndexesToCacheIndexes == null ) {
return ( (Object[]) row )[valueIndex];
}
else if ( row.getClass() != Object[].class ) {
assert valueIndexesToCacheIndexes[valueIndex] == 0;
return row;
else if ( row instanceof Object[] ) {
return ( (Object[]) row )[valueIndexesToCacheIndexes[valueIndex]];
}
else {
return ( (Object[]) row )[valueIndexesToCacheIndexes[valueIndex]];
assert valueIndexesToCacheIndexes[valueIndex] == 0;
return row;
}
}