{"record":{"id":"38d467a380957a50","repo":"hibernate/hibernate-orm","slug":"unsure-how-to-create-named-query-memento-for-nativ","errorCode":null,"errorMessage":"Unsure how to create named query memento for native query - ${query}","messagePattern":"Unsure how to create named query memento for native query - (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java","lineNumber":521,"sourceCode":"\t\t\t// as a last resort, see if the SQL starts with \"select\"\n\t\t\t|| startsWithSelect() ) {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic NamedNativeQueryMemento<R> toMemento(String name) {\n\t\tif ( isSelectQuery() == Boolean.TRUE ) {\n\t\t\treturn toSelectionMemento( name );\n\t\t}\n\t\telse if ( isSelectQuery() == Boolean.FALSE ) {\n\t\t\treturn toMutationMemento( name );\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalStateException( \"Unsure how to create named query memento for native query - \" + this );\n\t\t}\n\t}\n\n\t@Override\n\tpublic NativeMutationMementoImpl<R> toMutationMemento(String name) {\n\t\terrorIfSelectForSure();\n\t\tfinal var options = getQueryOptions();\n\t\treturn new NativeMutationMementoImpl<>(\n\t\t\t\tname,\n\t\t\t\toriginalSqlString,\n\t\t\t\tnull,\n\t\t\t\toptions.getQueryFlushMode(),\n\t\t\t\toptions.getTimeout(),\n\t\t\t\tgetComment(),\n\t\t\t\tgetHints(),\n\t\t\t\tquerySpaces\n\t\t);\n\t}","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java#L503-L539","documentation":"Error \"Unsure how to create named query memento for native query - ${query}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A runtime precondition of the Hibernate query API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["The query being converted to a named-query memento is not a supported native query shape; only memento-able native queries can be registered as named queries.","Define the named query via @NamedNativeQuery or orm.xml instead of converting an ad-hoc query."],"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"}