hibernate/hibernate-orm · error · IllegalArgumentException
Result-caching is not relevant for non-select NativeQuery
Error message
Result-caching is not relevant for non-select NativeQuery
What it means
Error "Result-caching is not relevant for non-select NativeQuery" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java:913
protected void applyReadOnlyHint(String hintName, Object value) {
if ( isNotSelectForSure() ) {
throw new IllegalArgumentException( "Read-only is not relevant for non-select NativeQuery" );
}
super.applyReadOnlyHint( hintName, value );
}
@Override
protected void applyFetchSizeHint(String hintName, Object value) {
if ( isNotSelectForSure() ) {
throw new IllegalArgumentException( "Fetch-size is not relevant for non-select NativeQuery" );
}
super.applyFetchSizeHint( hintName, value );
}
@Override
protected void applyResultCachingHint(String hintName, Object value) {
if ( isNotSelectForSure() ) {
throw new IllegalArgumentException( "Result-caching is not relevant for non-select NativeQuery" );
}
super.applyResultCachingHint( hintName, value );
}
@Override
protected void applyResultCacheModeHint(String hintName, Object value) {
if ( isNotSelectForSure() ) {
throw new IllegalArgumentException( "Result-caching is not relevant for non-select NativeQuery" );
}
super.applyResultCacheModeHint( hintName, value );
}
@Override
protected void applyResultCachingRetrieveModeHint(String hintName, Object value) {
if ( isNotSelectForSure() ) {
throw new IllegalArgumentException( "Result-caching is not relevant for non-select NativeQuery" );
}
super.applyResultCachingRetrieveModeHint( hintName, value );View on GitHub (pinned to fad1729dce)
Solutions
- Result caching only applies to selecting queries; the query is a non-select native query.
- Remove setCacheable/setCacheMode for mutation native queries.
When it happens
Trigger: An API operation is invoked on a query object that does not support it.
Common situations: Calling query hint, locking, pagination, conversion, or mutation APIs on a query kind (native vs HQL, select vs mutation) that does not implement them.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/e0aba0a53e39cd45.
Report an issue: GitHub.