hibernate/hibernate-orm · error · IllegalArgumentException
Could not create TypedQueryReference from given TypedQuery -
Error message
Could not create TypedQueryReference from given TypedQuery - {} What it means
Error "Could not create TypedQueryReference from given TypedQuery - {}" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/named/internal/NamedObjectRepositoryImpl.java:139
}
@Override
public void forEachNamedQuery(@Nonnull BiConsumer<String,? super TypedQueryReference<?>> action) {
selectionMementos.forEach( action );
}
@Override
@Nonnull
public <R> TypedQueryReference<R> registerNamedQuery(@Nonnull String name, @Nonnull TypedQuery<R> query) {
try {
final var refProducer = query.unwrap( TypedQueryReferenceProducer.class );
final var ref = refProducer.toSelectionMemento( name );
selectionMementos.put( name, ref );
//noinspection unchecked
return (TypedQueryReference<R>) ref;
}
catch (Exception e) {
throw new IllegalArgumentException( "Could not create TypedQueryReference from given TypedQuery - " + query, e );
}
}
@Override
@Nonnull
public Map<String, StatementReference> getNamedMutations() {
return Collections.unmodifiableMap( mutationMementos );
}
@Override
@Nonnull
public StatementReference registerNamedMutation(@Nonnull String name, @Nonnull Statement statement) {
try {
final var refProducer = statement.unwrap( StatementReferenceProducer.class );
final var ref = refProducer.toMutationMemento( name );
mutationMementos.put( name, ref );
return ref;
}View on GitHub (pinned to fad1729dce)
Solutions
- A TypedQueryReference could not be built from the given TypedQuery. Supply a proper named query reference with a result type.
When it happens
Trigger: A named-query reference cannot be built from the given object: Could not create TypedQueryReference from given TypedQuery - <value>
Common situations: Registering named queries from objects that are not proper TypedQuery/Statement instances.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/d0ba2cb894e81044.
Report an issue: GitHub.