{"record":{"id":"d0ba2cb894e81044","repo":"hibernate/hibernate-orm","slug":"could-not-create-typedqueryreference-from-given-ty","errorCode":null,"errorMessage":"Could not create TypedQueryReference from given TypedQuery - {}","messagePattern":"Could not create TypedQueryReference from given TypedQuery - (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/named/internal/NamedObjectRepositoryImpl.java","lineNumber":139,"sourceCode":"\t}\n\n\t@Override\n\tpublic void forEachNamedQuery(@Nonnull BiConsumer<String,? super TypedQueryReference<?>> action) {\n\t\tselectionMementos.forEach( action );\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic <R> TypedQueryReference<R> registerNamedQuery(@Nonnull String name, @Nonnull TypedQuery<R> query) {\n\t\ttry {\n\t\t\tfinal var refProducer = query.unwrap( TypedQueryReferenceProducer.class );\n\t\t\tfinal var ref = refProducer.toSelectionMemento( name );\n\t\t\tselectionMementos.put( name, ref );\n\t\t\t//noinspection unchecked\n\t\t\treturn (TypedQueryReference<R>) ref;\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new IllegalArgumentException( \"Could not create TypedQueryReference from given TypedQuery - \" + query, e );\n\t\t}\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic Map<String, StatementReference> getNamedMutations() {\n\t\treturn Collections.unmodifiableMap( mutationMementos );\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic StatementReference registerNamedMutation(@Nonnull String name, @Nonnull Statement statement) {\n\t\ttry {\n\t\t\tfinal var refProducer = statement.unwrap( StatementReferenceProducer.class );\n\t\t\tfinal var ref = refProducer.toMutationMemento( name );\n\t\t\tmutationMementos.put( name, ref );\n\t\t\treturn ref;\n\t\t}","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/named/internal/NamedObjectRepositoryImpl.java#L121-L157","documentation":"Error \"Could not create TypedQueryReference from given TypedQuery - {}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A named-query reference cannot be built from the given object: Could not create TypedQueryReference from given TypedQuery - <value>","commonSituations":"Registering named queries from objects that are not proper TypedQuery/Statement instances.","solutions":["A TypedQueryReference could not be built from the given TypedQuery. Supply a proper named query reference with a result type."],"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"}