{"record":{"id":"5fb001ad0b177741","repo":"hibernate/hibernate-orm","slug":"the-predicate-array-cannot-be-null","errorCode":null,"errorMessage":"The predicate array cannot be null","messagePattern":"The predicate array cannot be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/select/SqmQuerySpec.java","lineNumber":391,"sourceCode":"\t@Override\n\tpublic SqmQuerySpec<T> setRestriction(BooleanExpression... restrictions) {\n\t\tif ( restrictions.length == 0 ) {\n\t\t\tsetWhereClause( null );\n\t\t}\n\t\telse {\n\t\t\tSqmWhereClause whereClause = getWhereClause();\n\t\t\tif ( whereClause == null ) {\n\t\t\t\tsetWhereClause( whereClause = new SqmWhereClause( nodeBuilder() ) );\n\t\t\t}\n\t\t\twhereClause.setPredicate( nodeBuilder().wrap( restrictions ) );\n\t\t}\n\t\treturn this;\n\t}\n\n\t@Nonnull\n\tpublic SqmQuerySpec<T> setRestriction(@Nullable Predicate... restrictions) {\n\t\tif ( restrictions == null ) {\n\t\t\tthrow new IllegalArgumentException( \"The predicate array cannot be null\" );\n\t\t}\n\t\telse if ( restrictions.length == 0 ) {\n\t\t\tsetWhereClause( null );\n\t\t}\n\t\telse {\n\t\t\tfinal var whereClause = resetWhereClause();\n\t\t\tfor ( var restriction : restrictions ) {\n\t\t\t\twhereClause.applyPredicate( (SqmPredicate) restriction );\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t@Nonnull\n\t@Override\n\tpublic SqmQuerySpec<T> setRestriction(List<Predicate> restrictions) {\n\t\tif ( restrictions == null ) {\n\t\t\tthrow new IllegalArgumentException( \"The predicate list cannot be null\" );","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/select/SqmQuerySpec.java#L373-L409","documentation":"Error \"The predicate array cannot be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A restriction method is invoked with a null Predicate array (varargs) on a criteria query specification.","commonSituations":"Passing a null Predicate[] variable to where()/having(); check for null before the call.","solutions":["Pass a non-null array of predicates; use an empty array if no restriction is needed, or skip the call entirely.","Check for null before calling and guard the call site."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}