hibernate/hibernate-orm · error · IllegalArgumentException
RemovalsMode.EXCLUDE is incompatible with OrderingMode.ORDER
Error message
RemovalsMode.EXCLUDE is incompatible with OrderingMode.ORDERED
What it means
Error "RemovalsMode.EXCLUDE is incompatible with OrderingMode.ORDERED" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractMultiIdEntityLoader.java:228
List<Object> result,
int i) {
return !loadOptions.isRefreshSession()
&& (loadOptions.getSessionCheckMode() == FindMultipleOption.SessionCheckMode.ENABLED
|| loadOptions.isSecondLevelCacheCheckingEnabled() )
&& isLoadFromCaches( loadOptions, entityKey, lockOptions, result, i, session );
}
private boolean isLoadFromCaches(
MultiIdLoadOptions loadOptions,
EntityKey entityKey,
LockOptions lockOptions,
List<Object> results, int i,
SharedSessionContractImplementor session) {
if ( loadOptions.getSessionCheckMode() == FindMultipleOption.SessionCheckMode.ENABLED ) {
final var removalsMode = loadOptions.getRemovalsMode();
if ( removalsMode == FindMultipleOption.RemovalsMode.EXCLUDE ) {
// note, this method is only called from orderedMultiLoad()
throw new IllegalArgumentException( "RemovalsMode.EXCLUDE is incompatible with OrderingMode.ORDERED" );
}
// look for it in the Session first
final var entry = loadFromSessionCache( entityKey, lockOptions, GET, session );
final Object entity = entry.entity();
if ( entity != null ) {
// put a null in the results
final Object result =
loadOptions.getRemovalsMode() == FindMultipleOption.RemovalsMode.INCLUDE
|| entry.isManaged()
? entity
: null;
results.add( i, result );
return true;
}
}
if ( loadOptions.isSecondLevelCacheCheckingEnabled() ) {
// look for it in the second-level cacheView on GitHub (pinned to fad1729dce)
Solutions
- Do not combine RemovalsMode.EXCLUDE with OrderingMode.ORDERED in multi-id loading; choose REMOVALS mode NONE/INCLUDE or unordered loading.
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractMultiIdEntityLoader.java:228 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/a39cc948b9818639.
Report an issue: GitHub.