{"record":{"id":"a39cc948b9818639","repo":"hibernate/hibernate-orm","slug":"removalsmode-exclude-is-incompatible-with-ordering","errorCode":null,"errorMessage":"RemovalsMode.EXCLUDE is incompatible with OrderingMode.ORDERED","messagePattern":"RemovalsMode\\.EXCLUDE is incompatible with OrderingMode\\.ORDERED","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractMultiIdEntityLoader.java","lineNumber":228,"sourceCode":"\t\t\tList<Object> result,\n\t\t\tint i) {\n\t\treturn !loadOptions.isRefreshSession()\n\t\t\t&& (loadOptions.getSessionCheckMode() == FindMultipleOption.SessionCheckMode.ENABLED\n\t\t\t\t|| loadOptions.isSecondLevelCacheCheckingEnabled() )\n\t\t\t&& isLoadFromCaches( loadOptions, entityKey, lockOptions, result, i, session );\n\t}\n\n\tprivate boolean isLoadFromCaches(\n\t\t\tMultiIdLoadOptions loadOptions,\n\t\t\tEntityKey entityKey,\n\t\t\tLockOptions lockOptions,\n\t\t\tList<Object> results, int i,\n\t\t\tSharedSessionContractImplementor session) {\n\t\tif ( loadOptions.getSessionCheckMode() == FindMultipleOption.SessionCheckMode.ENABLED ) {\n\t\t\tfinal var removalsMode = loadOptions.getRemovalsMode();\n\t\t\tif ( removalsMode == FindMultipleOption.RemovalsMode.EXCLUDE ) {\n\t\t\t\t// note, this method is only called from orderedMultiLoad()\n\t\t\t\tthrow new IllegalArgumentException( \"RemovalsMode.EXCLUDE is incompatible with OrderingMode.ORDERED\" );\n\t\t\t}\n\t\t\t// look for it in the Session first\n\t\t\tfinal var entry = loadFromSessionCache( entityKey, lockOptions, GET, session );\n\t\t\tfinal Object entity = entry.entity();\n\t\t\tif ( entity != null ) {\n\t\t\t\t// put a null in the results\n\t\t\t\tfinal Object result =\n\t\t\t\t\t\tloadOptions.getRemovalsMode() == FindMultipleOption.RemovalsMode.INCLUDE\n\t\t\t\t\t\t\t|| entry.isManaged()\n\t\t\t\t\t\t\t\t? entity\n\t\t\t\t\t\t\t\t: null;\n\t\t\t\tresults.add( i, result );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif ( loadOptions.isSecondLevelCacheCheckingEnabled() ) {\n\t\t\t// look for it in the second-level cache","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractMultiIdEntityLoader.java#L210-L246","documentation":"Error \"RemovalsMode.EXCLUDE is incompatible with OrderingMode.ORDERED\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractMultiIdEntityLoader.java:228 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not combine RemovalsMode.EXCLUDE with OrderingMode.ORDERED in multi-id loading; choose REMOVALS mode NONE/INCLUDE or unordered loading."],"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"}