{"record":{"id":"902a484414e254ec","repo":"hibernate/hibernate-orm","slug":"key-definition-must-not-null","errorCode":null,"errorMessage":"Key definition must not null","messagePattern":"Key definition must not null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/Page.java","lineNumber":149,"sourceCode":"\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) {\n\t\tif ( keyDefinition == null )  {\n\t\t\tthrow new IllegalArgumentException(\"Key definition must not null\");\n\t\t}\n\t\treturn new KeyedPage<>( List.of(keyDefinition), this );\n\t}\n\n\t/**\n\t * Obtain a {@linkplain KeyedPage key-based specification} of this page.\n\t *\n\t * @param keyDefinition a list of {@link Order} objects defining a total\n\t *                      order 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(List<Order<? super R>> keyDefinition) {\n\t\tif ( keyDefinition == null || keyDefinition.isEmpty() )  {\n\t\t\tthrow new IllegalArgumentException(\"Key definition must not be empty or null\");\n\t\t}\n\t\treturn new KeyedPage<>( keyDefinition, this );","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/Page.java#L131-L167","documentation":"Error \"Key definition must not null\" thrown in hibernate/hibernate-orm.","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":["Provide a non-null key definition for keyset pagination.","Build the Page with a valid key reference."],"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"}