{"record":{"id":"1cb6207dd658286d","repo":"hibernate/hibernate-orm","slug":"fetch-clause-may-not-be-null","errorCode":null,"errorMessage":"Fetch clause may not be null","messagePattern":"Fetch clause may not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/select/SqmQueryPart.java","lineNumber":118,"sourceCode":"\tpublic void setOffsetExpression(@Nullable SqmExpression<? extends Number> offsetExpression) {\n\t\tif ( offsetExpression != null ) {\n\t\t\toffsetExpression.applyInferableType( nodeBuilder.getIntegerType() );\n\t\t}\n\t\tthis.offsetExpression = offsetExpression;\n\t}\n\n\tpublic void setFetchExpression(@Nullable SqmExpression<? extends Number> fetchExpression) {\n\t\tsetFetchExpression( fetchExpression, FetchClauseType.ROWS_ONLY );\n\t}\n\n\tpublic void setFetchExpression(@Nullable SqmExpression<? extends Number> fetchExpression, FetchClauseType fetchClauseType) {\n\t\tif ( fetchExpression == null ) {\n\t\t\tthis.fetchExpression = null;\n\t\t\tthis.fetchClauseType = FetchClauseType.ROWS_ONLY;\n\t\t}\n\t\telse {\n\t\t\tif ( fetchClauseType == null ) {\n\t\t\t\tthrow new IllegalArgumentException( \"Fetch clause may not be null\" );\n\t\t\t}\n\t\t\tfetchExpression.applyInferableType( nodeBuilder.getIntegerType() );\n\t\t\tthis.fetchExpression = fetchExpression;\n\t\t\tthis.fetchClauseType = fetchClauseType;\n\t\t}\n\t}\n\n\t@Override\n\tpublic FetchClauseType getFetchClauseType() {\n\t\treturn fetchClauseType;\n\t}\n\n\t// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t// JPA\n\n\t@Override\n\t@Nonnull\n\tpublic List<SqmSortSpecification> getSortSpecifications() {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/select/SqmQueryPart.java#L100-L136","documentation":"Error \"Fetch clause may not be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A fetch clause is set on a query part while JPA compliance checking rejects a null/absent fetch value.","commonSituations":"Calling setFetchClause with a null expression; supply a valid fetch expression.","solutions":["Pass a non-null FetchClauseType to the fetch clause API (e.g. FetchClauseType.ROWS_ONLY, ROWS_FIRST, ROWS_WITH_TIES).","If no fetch clause is needed, do not call the fetch method at all instead of passing null."],"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"}