{"record":{"id":"ec1872bbf59a7fa9","repo":"hibernate/hibernate-orm","slug":"not-a-select-query-ec1872","errorCode":null,"errorMessage":"Not a select query","messagePattern":"Not a select query","errorType":"exception","errorClass":"IllegalSelectQueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java","lineNumber":725,"sourceCode":"\t@Nonnull\n\tpublic QueryParameterBindings getParameterBindings() {\n\t\treturn getQueryParameterBindings();\n\t}\n\n\t@Override\n\tpublic Class<R> getResultType() {\n\t\terrorIfNotSelectForSure();\n\t\treturn resultType;\n\t}\n\n\tprivate boolean isNotSelectForSure() {\n\t\treturn isSelectQuery() == Boolean.FALSE;\n\t}\n\n\tprivate void errorIfNotSelectForSure() {\n\t\tif ( isNotSelectForSure() ) {\n\t\t\t// we unequivocally know it IS NOT a select query\n\t\t\tthrow new IllegalSelectQueryException( \"Not a select query\", sqlString );\n\t\t}\n\t}\n\n\tprivate void errorIfSelectForSure() {\n\t\tif ( isSelectQuery() == Boolean.TRUE ) {\n\t\t\t// we unequivocally know it IS a select query\n\t\t\tthrow new IllegalSelectQueryException( \"Not a mutation query\", sqlString );\n\t\t}\n\t}\n\n\t@Override\n\t@Nullable\n\tpublic Class<R> getTargetType() {\n\t\treturn resultType;\n\t}\n\n\t@Override\n\t@Nonnull","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java#L707-L743","documentation":"Error \"Not a select query\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A query object is used through an interface or role it does not implement.","commonSituations":"Casting or unwrapping a native/HQL, select/mutation query to the wrong type, or passing a non-property path where one is required.","solutions":["The method was called on a mutation native query but requires a SELECT query.","Use a SELECT native query, or use executeUpdate() for mutation 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"}