hibernate/hibernate-orm · error · QueryParameterException
No argument for named parameter ':{}'
Error message
No argument for named parameter ':{}' What it means
Before a query executes, QueryParameterBindingsImpl.validate() walks every declared parameter and throws QueryParameterException naming the first unbound one. Hibernate does not substitute null or ignore missing named arguments, so every :name in the HQL must receive a setParameter call before list()/getResultList()/executeUpdate().
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingsImpl.java:172
}
@Override
public QueryParameterBinding<?> getBinding(String name) {
final var binding = parameterBindingMapByNameOrPosition.get( name );
if ( binding == null ) {
// Invoke this method to throw the exception
parameterMetadata.getQueryParameter( name );
}
return binding;
}
@Override
public void validate() {
for ( var entry : parameterBindingMap.entrySet() ) {
if ( !entry.getValue().isBound() ) {
final var queryParameter = entry.getKey();
if ( queryParameter.isNamed() ) {
throw new QueryParameterException(
"No argument for named parameter ':"
+ queryParameter.getName() + "'" );
}
else {
throw new QueryParameterException(
"No argument for ordinal parameter '?"
+ queryParameter.getPosition() + "'" );
}
}
}
}
@Override
public boolean hasAnyMultiValuedBindings() {
for ( var binding : parameterBindingMap.values() ) {
if ( binding.isMultiValued() ) {
return true;
}View on GitHub (pinned to fad1729dce)
Solutions
- Set every declared parameter before execution; the message names the missing one.
- Build the predicate and its binding in the same conditional block so they cannot diverge.
- For genuinely optional filters, omit the whole predicate when the value is absent (dynamic query building or Criteria with optional predicates).
Example fix
// before
var q = session.createQuery("from Person p where p.status = :status", Person.class);
// setParameter forgotten
q.list(); // throws: No argument for named parameter ':status'
// after
q.setParameter("status", status != null ? status : Status.ACTIVE);
// or: append "and p.status = :status" to the HQL only when you also bind it Defensive patterns
Strategy: validation
Validate before calling
static void assertAllBound(org.hibernate.query.Query<?> q, java.util.Set<String> boundNames) {
for (String name : q.getParameterMetadata().getNamedParameterNames()) {
if (!boundNames.contains(name))
throw new IllegalArgumentException("Unbound parameter :" + name);
}
} Try / catch
try {
return q.list();
} catch (org.hibernate.QueryParameterException e) {
// message names the missing ':name'; log and surface as a 400
} Prevention
- Append predicate and binding together in dynamic builders.
- Execute each repository method once in tests to flush missing bindings.
- Treat optional filters by omitting the predicate, not by skipping the bind.
When it happens
Trigger: createQuery("... where p.status = :status") executed without any setParameter("status", ...); a dynamic filter builder that appends the predicate but skips the binding on some branch, or binds after a conditional early return.
Common situations: Optional search filters where one code path forgets the bind; refactors that rename a parameter only in the HQL; new parameters added to a shared query string without updating all call sites.
Related errors
- No argument for ordinal parameter '?{}'
- No parameter named ':%s' in query with named parameters [%s]
- Insert conflict 'do update' clause with constraint name is n
- field type not supported on Derby: " + unit
- format() function not supported on Derby
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/923c170783afea2e.
Report an issue: GitHub.