{"record":{"id":"f5322e0af21720e1","repo":"hibernate/hibernate-orm","slug":"already-at-first-page","errorCode":null,"errorMessage":"already at first page","messagePattern":"already at first page","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/Page.java","lineNumber":129,"sourceCode":"\t */\n\tpublic static Page first(int size) {\n\t\treturn new Page( size, 0 );\n\t}\n\n\t/**\n\t * Obtain the next page with the same size as this page.\n\t */\n\tpublic Page next() {\n\t\treturn new Page( size, number+1 );\n\t}\n\n\t/**\n\t * Obtain the previous page with the same size as this page.\n\t * @throws IllegalStateException if this is the first page\n\t */\n\tpublic Page previous() {\n\t\tif ( isFirst() ) {\n\t\t\tthrow new IllegalStateException(\"already at first page\");\n\t\t}\n\t\treturn new Page( size, number-1 );\n\t}\n\n\tpublic Page first() {\n\t\treturn first( size );\n\t}\n\n\t/**\n\t * Obtain a {@linkplain KeyedPage key-based specification} of this page.\n\t *\n\t * @param keyDefinition an {@link Order} object defining a total order\n\t *                      on the result set\n\t * @return a {@link KeyedPage} representing this page\n\t *\n\t * @since 6.5\n\t */\n\tpublic <R> KeyedPage<R> keyedBy(Order<? super R> keyDefinition) {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/Page.java#L111-L147","documentation":"Navigation guard in Page.previous(): the current page is already page zero (isFirst() true), so there is no previous page to return and the IllegalStateException documented on previous() is thrown. The faulty input is calling previous() without first checking isFirst(); guard navigation or iterate with page numbers.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["Check hasPrevious()/page number before navigating to the previous page.","Guard navigation logic at the first page boundary."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}