{"record":{"id":"a1cf0819b41d9c97","repo":"hibernate/hibernate-orm","slug":"named-query-s-was-not-a-native-query","errorCode":null,"errorMessage":"Named query (%s) was not a native-query","messagePattern":"Named query \\((.+?)\\) was not a native-query","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java","lineNumber":2900,"sourceCode":"\n\t\teventListenerGroups = getFactory().getEventListenerGroups();\n\t}\n\n\t// Used by Hibernate reactive\n\tprotected Boolean getReadOnlyFromLoadQueryInfluencers() {\n\t\treturn loadQueryInfluencers.getReadOnly();\n\t}\n\n\t@Override @Deprecated\n\t@SuppressWarnings({\"rawtypes\", \"removal\"})\n\t@Nonnull\n\tpublic NativeQueryImplementor getNamedNativeQuery(@Nonnull String name) {\n\t\tfinal var query = createNamedQuery( name );\n\t\tif ( query instanceof NativeQueryImplementor nativeQueryImplementor ) {\n\t\t\treturn nativeQueryImplementor;\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalStateException( String.format( Locale.ROOT,\n\t\t\t\t\t\"Named query (%s) was not a native-query\",\n\t\t\t\t\tname\n\t\t\t) );\n\t\t}\n\t}\n}\n","sourceCodeStart":2882,"sourceCodeEnd":2907,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java#L2882-L2907","documentation":"Error \"Named query (%s) was not a native-query\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:2900 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use createNativeQuery with a named native query (@NamedNativeQuery), or use createNamedQuery for HQL/JPQL named queries.","Verify the named query type matches the API you are calling."],"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"}