{"record":{"id":"0bb7de3696e0d433","repo":"hibernate/hibernate-orm","slug":"keyedpage-was-null","errorCode":null,"errorMessage":"KeyedPage was null","messagePattern":"KeyedPage was null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/internal/SelectionQueryImpl.java","lineNumber":1041,"sourceCode":"\t\tfinal var context = new DelegatingDomainQueryExecutionContext(this) {\n\t\t\t@Override\n\t\t\tpublic QueryOptions getQueryOptions() {\n\t\t\t\treturn QueryOptions.NONE;\n\t\t\t}\n\t\t};\n\t\tfinal var queryPlan = buildConcreteQueryPlan(\n\t\t\t\tgetSqmStatement().createCountQuery(),\n\t\t\t\tLong.class,\n\t\t\t\tnull,\n\t\t\t\tqueryOptions\n\t\t);\n\t\treturn queryPlan.executeQuery( context, SingleResultConsumer.instance() );\n\t}\n\n\t@Override\n\tpublic KeyedResultList<R> getKeyedResultList(KeyedPage<R> keyedPage) {\n\t\tif ( keyedPage == null ) {\n\t\t\tthrow new IllegalArgumentException( \"KeyedPage was null\" );\n\t\t}\n\t\tfinal var results =\n\t\t\t\tnew SelectionQueryImpl<KeyedResult<R>>( this, keyedPage )\n\t\t\t\t\t\t.getResultList();\n\t\tfinal int pageSize = keyedPage.getPage().getSize();\n\t\treturn new KeyedResultList<>(\n\t\t\t\tcollectResults( results, pageSize, keyedPage.getKeyInterpretation() ),\n\t\t\t\tcollectKeys( results, pageSize ),\n\t\t\t\tkeyedPage,\n\t\t\t\tnextPage( keyedPage, results ),\n\t\t\t\tpreviousPage( keyedPage, results )\n\t\t);\n\t}\n\n\t// Used by Hibernate Reactive\n\tpublic static <R> KeyedPage<R> nextPage(KeyedPage<R> keyedPage, List<KeyedResult<R>> results) {\n\t\tif ( keyedPage.getKeyInterpretation() == KEY_OF_FIRST_ON_NEXT_PAGE ) {\n\t\t\t// the results come in reverse order","sourceCodeStart":1023,"sourceCodeEnd":1059,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/internal/SelectionQueryImpl.java#L1023-L1059","documentation":"Error \"KeyedPage was null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Key-based pagination preconditions are not met: KeyedPage was null","commonSituations":"Using key-based pagination on queries with no/multiple roots, multi-item select lists, non-entity select items, or pages containing null key values.","solutions":["A null KeyedPage was supplied. Pass a non-null KeyedPage (from a previous page result) to fetch the next page."],"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"}