After update to hibernate from 6.1.7 to 6.4.1 I received an error java.lang.NullPointerException: Cannot invoke “org.hibernate.query.sqm.SqmExpressible.getSqmType()” because the return value of “org.hibernate.query.sqm.tree.SqmTypedNode.getExpressible()” is null
As I understand that because of usage SqmCollation but how can I set predefined array to function array_position? I don’t found any expression for arrays
As I see validation added in class org.hibernate.dialect.function.array.ArrayArgumentValidator and method getPluralType
protected BasicPluralType<?, ?> getPluralType(
int arrayIndex,
List<? extends SqmTypedNode<?>> arguments,
String functionName,
TypeConfiguration typeConfiguration) {
final SqmTypedNode<?> arrayArgument = arguments.get( arrayIndex );
final SqmExpressible<?> arrayType = arrayArgument.getExpressible().getSqmType();
if ( arrayType == null ) {
return null;
}
else if ( !( arrayType instanceof BasicPluralType<?, ?> ) ) {
throw new FunctionArgumentException(
String.format(
"Parameter %d of function '%s()' requires an array type, but argument is of type '%s'",
arrayIndex,
functionName,
arrayType.getTypeName()
)
);
}
return (BasicPluralType<?, ?>) arrayType;
}
Thank you for your help on investigating this issue on my side. To give a bit more context, here is the Custom FunctionContributor :
public class CustomPostgresFunctionContributor implements FunctionContributor {
public void contributeFunctions(FunctionContributions functionContributions) {
var booleanType = functionContributions.getTypeConfiguration().getBasicTypeRegistry().resolve(StandardBasicTypes.BOOLEAN);
functionContributions.getFunctionRegistry().registerPattern("anyInArray", "?1 && array[?2]", booleanType);
}
}
It used to work like this before (on HIbernate 6.2.17.Final):
org.hibernate.SQL : select * from my_table mp1_0 where mp1_0.status = ? and ? && array[mp1_0.users]
org.hibernate.orm.jdbc.bind : binding parameter [1] as [VARCHAR] - [activated]
org.hibernate.orm.jdbc.bind : binding parameter [2] as [ARRAY] - [[Ljava.lang.String;@4f056eee]
org.hibernate.orm.jdbc.bind : binding parameter [2] as [ARRAY] - [[user1, user2]]
But with Hibernate 6.4.3 :
org.hibernate.SQL : select * from my_table mp1_0 where mp1_0.status = ? and [Ljava.lang.String;@717dc557 && array[mp1_0.users]
org.hibernate.orm.jdbc.bind : binding parameter (1:VARCHAR) <- [activated]
o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: syntax error at or near "["
I suppose that I’m doing something wrong while passing the array values to the code (something that should’nt be working but worked on 6.2.x but not anymore)
Not sure if it’s a final working solution, because it’s based on the implementation and not the Interface (CriteriaBuilder).
HibernateCriteriaBuilder is not the implementation but rather the extension to the JPA contract CriteriaBuilder. This is fine and the appropriate solution.