{"record":{"id":"5cd064b4494b0348","repo":"hibernate/hibernate-orm","slug":"respect-nulls-or-ignore-nulls-are-illegal-for","errorCode":null,"errorMessage":"'RESPECT NULLS' or 'IGNORE NULLS' are illegal for function: {functionName}","messagePattern":"'RESPECT NULLS' or 'IGNORE NULLS' are illegal for function: (.+?)","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":4748,"sourceCode":"\t\t\t\t\t\tquery );\n\t\t\t}\n\t\t\tif ( ctx.withinGroupClause() == null && ctx.overClause() == null\n\t\t\t\t\t&& functionKind == FunctionKind.ORDERED_SET_AGGREGATE ) {\n\t\t\t\tthrow new SemanticException( \"'WITHIN GROUP' or 'OVER' clause is mandatory for ordered set aggregate function: \"\n\t\t\t\t\t\t+ functionName,\n\t\t\t\t\t\tquery );\n\t\t\t}\n\n\t\t\tif ( ctx.nullsClause() != null ) {\n\t\t\t\tswitch ( functionName ) {\n\t\t\t\t\tcase \"lag\":\n\t\t\t\t\tcase \"lead\":\n\t\t\t\t\tcase \"first_value\":\n\t\t\t\t\tcase \"last_value\":\n\t\t\t\t\tcase \"nth_value\":\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new SemanticException( \"'RESPECT NULLS' or 'IGNORE NULLS' are illegal for function: \"\n\t\t\t\t\t\t\t\t+ functionName,\n\t\t\t\t\t\t\t\tquery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ctx.nthSideClause() != null && !\"nth_value\".equals( functionName ) ) {\n\t\t\t\tthrow new SemanticException( \"'FROM FIRST' or 'FROM LAST' are illegal for function: \"\n\t\t\t\t\t\t+ functionName,\n\t\t\t\t\t\tquery );\n\t\t\t}\n\t\t\treturn functionTemplate;\n\t\t}\n\t}\n\n\tprivate static FunctionKind inferFunctionKind(HqlParser.GenericFunctionContext ctx) {\n\t\tif ( ctx.withinGroupClause() != null ) {\n\t\t\treturn FunctionKind.ORDERED_SET_AGGREGATE;\n\t\t}\n\t\telse if ( ctx.overClause() != null ) {","sourceCodeStart":4730,"sourceCodeEnd":4766,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L4730-L4766","documentation":"Error \"'RESPECT NULLS' or 'IGNORE NULLS' are illegal for function: {functionName}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An aggregate/window clause is applied to a function that does not accept it: 'RESPECT NULLS' or 'IGNORE NULLS' are illegal for function: <value>","commonSituations":"HQL queries that attach FILTER, OVER, WITHIN GROUP, RESPECT/IGNORE NULLS, or FROM FIRST/LAST to functions that are not aggregate or window functions, or omit a mandatory OVER/WITHIN GROUP clause.","solutions":["RESPECT NULLS / IGNORE NULLS is only valid for the window functions that support it. Remove the clause from this function call."],"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"}