{"record":{"id":"63812bdb87a86e58","repo":"hibernate/hibernate-orm","slug":"read-only-is-not-relevant-for-non-select-nativeque","errorCode":null,"errorMessage":"Read-only is not relevant for non-select NativeQuery","messagePattern":"Read-only is not relevant for non-select NativeQuery","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java","lineNumber":897,"sourceCode":"\t\tif ( mapping instanceof EntityMapping<?> entityMapping ) {\n\t\t\tfinal var lockMode = LockMode.fromJpaLockMode( entityMapping.lockMode() );\n\t\t\tif ( lockMode.greaterThan( LockMode.READ ) ) {\n\t\t\t\tsetHibernateLockMode( lockMode );\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\t@Nullable\n\tpublic PessimisticLockScope getLockScope() {\n\t\t//noinspection removal\n\t\treturn queryOptions.getLockOptions().getLockScope();\n\t}\n\n\t@Override\n\tprotected void applyReadOnlyHint(String hintName, Object value) {\n\t\tif ( isNotSelectForSure() ) {\n\t\t\tthrow new IllegalArgumentException( \"Read-only is not relevant for non-select NativeQuery\" );\n\t\t}\n\t\tsuper.applyReadOnlyHint( hintName, value );\n\t}\n\n\t@Override\n\tprotected void applyFetchSizeHint(String hintName, Object value) {\n\t\tif ( isNotSelectForSure() ) {\n\t\t\tthrow new IllegalArgumentException( \"Fetch-size is not relevant for non-select NativeQuery\" );\n\t\t}\n\t\tsuper.applyFetchSizeHint( hintName, value );\n\t}\n\n\t@Override\n\tprotected void applyResultCachingHint(String hintName, Object value) {\n\t\tif ( isNotSelectForSure() ) {\n\t\t\tthrow new IllegalArgumentException( \"Result-caching is not relevant for non-select NativeQuery\" );\n\t\t}\n\t\tsuper.applyResultCachingHint( hintName, value );","sourceCodeStart":879,"sourceCodeEnd":915,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java#L879-L915","documentation":"Error \"Read-only is not relevant for non-select NativeQuery\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An API operation is invoked on a query object that does not support it.","commonSituations":"Calling query hint, locking, pagination, conversion, or mutation APIs on a query kind (native vs HQL, select vs mutation) that does not implement them.","solutions":["setReadOnly only applies to selecting queries; the query is a non-select native query.","Remove the setReadOnly call for mutation native queries."],"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"}