hibernate/hibernate-orm · error · UnsupportedOperationException
Registering lock modes should only be done for result set…
Error message
Registering lock modes should only be done for result set mappings
What it means
Sentinel UnsupportedOperationException from LoaderSqlAstCreationState.registerLockMode: this SQL-AST creation state is built for load-by-key operations, not result-set mappings, so per-alias lock-mode registration is not supported here.
Solutions
- Only apply lock modes on result set mappings, not on scalar/other result types; adjust the native query lock mode registration.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSqlAstCreationState.java:177 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/9952943e99588c0f.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSqlAstCreationState.java:177
@Override
public SqlAliasBaseGenerator getSqlAliasBaseGenerator() {
return sqlAliasBaseManager;
}
@Override
public LoadQueryInfluencers getLoadQueryInfluencers() {
return loadQueryInfluencers;
}
@Override
public boolean applyOnlyLoadByKeyFilters() {
return true;
}
@Override
public void registerLockMode(String identificationVariable, LockMode explicitLockMode) {
throw new UnsupportedOperationException( "Registering lock modes should only be done for result set mappings" );
}
@Override
public ImmutableFetchList visitFetches(FetchParent fetchParent) {
return fetchProcessor.visitFetches( fetchParent, this );
}
@Override
public <R> R withNestedFetchParent(FetchParent fetchParent, Function<FetchParent, R> action) {
final var nestingFetchParent = processingState.getNestingFetchParent();
processingState.setNestingFetchParent( fetchParent );
final R result = action.apply( fetchParent );
processingState.setNestingFetchParent( nestingFetchParent );
return result;
}
@Override
public boolean isResolvingCircularFetch() {View on GitHub (pinned to fad1729dce)