hibernate/hibernate-orm · error · IllegalStateException
The parameter at position{position} has no argument
Error message
The parameter at position{position} has no argument What it means
Thrown (IllegalStateException) by getParameterValue(int position) — the positional twin of error 2372 — when the binding for that ordinal position exists but is not bound. The message is built as "The parameter at position" + position (note: a missing space in the source produces text like 'position1'). Unknown positions fail earlier inside getBinding(int) with a different exception.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/internal/AbstractCommonQueryContract.java:965
}
@Override
public Object getParameterValue(@Nonnull String name) {
session.checkOpen( false );
final var binding = getQueryParameterBindings().getBinding( name );
if ( !binding.isBound() ) {
throw new IllegalStateException( "The parameter named '" + name + "' has no argument" );
}
return binding.isMultiValued() ? binding.getBindValues() : binding.getBindValue();
}
@Override
@Nullable
public Object getParameterValue(int position) {
session.checkOpen( false );
final var binding = getQueryParameterBindings().getBinding( position );
if ( !binding.isBound() ) {
throw new IllegalStateException( "The parameter at position" + position + " has no argument" );
}
return binding.isMultiValued() ? binding.getBindValues() : binding.getBindValue();
}
private <P> JavaType<P> getJavaType(Class<P> javaType) {
return getTypeConfiguration().getJavaTypeRegistry()
.resolveDescriptor( javaType );
}
private <P> Type<P> getParamType(Class<P> javaType) {
final var basicType = getTypeConfiguration().standardBasicTypeForJavaType( javaType );
return basicType != null ? basicType : getSessionFactory().getJpaMetamodel().managedType( javaType );
}
protected QueryParameterBinding<?> locateBinding(Parameter<?> parameter) {
if ( parameter instanceof QueryParameterImplementor<?> parameterImplementor ) {
session.checkOpen();
return getQueryParameterBindings().getBinding( getQueryParameter( parameterImplementor ) );View on GitHub (pinned to fad1729dce)
Solutions
- Bind every positional parameter before reading (explicit null is fine for single-valued ones)
- Check bound-ness first: query.isBound(query.getParameter(position))
- For optional positional values, bind a sentinel/null so the contract stays satisfied
Example fix
// before Object v = query.getParameterValue( 2 ); // ISE: at position2 has no argument // after query.setParameter( 1, id ); query.setParameter( 2, statusOrNull ); Object v = query.getParameterValue( 2 );
Defensive patterns
Strategy: validation
Validate before calling
if ( !query.isBound( query.getParameter( position ) ) ) {
throw new IllegalStateException( "Parameter " + position + " not bound yet" );
}
Object v = query.getParameterValue( position ); Try / catch
try {
return query.getParameterValue( position );
} catch ( IllegalStateException e ) {
return null;
} Prevention
- Bind every '?' before reading values back
- Prefer named parameters in dynamic queries to avoid positional drift
- Add an integration test that binds and then reads all parameters
When it happens
Trigger: query.getParameterValue(1) before query.setParameter(1, ...). Reading positional values in a logger/auditor that runs before the DAO binds arguments; native queries with ?1..?n where the caller skipped an optional middle parameter.
Common situations: Parameter-order refactors where binding loops shift indices; audit/logging interceptors firing too early in the request lifecycle; migrations from named to positional parameters with leftover read code.
Related errors
- Parameter value not yet bound : {param}
- The parameter named '{name}' has no argument
- Type specified for parameter at position {position} is incom
- The parameter [{param}] is not part of this Query
- Null value not allowed for multi-valued parameter ':{name}'
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/c6ea3131718bf9f8.
Report an issue: GitHub.