{"record":{"id":"c6ea3131718bf9f8","repo":"hibernate/hibernate-orm","slug":"the-parameter-at-position-position-has-no-argumen","errorCode":null,"errorMessage":"The parameter at position{position} has no argument","messagePattern":"The parameter at position(.+?) has no argument","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/internal/AbstractCommonQueryContract.java","lineNumber":965,"sourceCode":"\t}\n\n\t@Override\n\tpublic Object getParameterValue(@Nonnull String name) {\n\t\tsession.checkOpen( false );\n\t\tfinal var binding = getQueryParameterBindings().getBinding( name );\n\t\tif ( !binding.isBound() ) {\n\t\t\tthrow new IllegalStateException( \"The parameter named '\" + name + \"' has no argument\" );\n\t\t}\n\t\treturn binding.isMultiValued() ? binding.getBindValues() : binding.getBindValue();\n\t}\n\n\t@Override\n\t@Nullable\n\tpublic Object getParameterValue(int position) {\n\t\tsession.checkOpen( false );\n\t\tfinal var binding = getQueryParameterBindings().getBinding( position );\n\t\tif ( !binding.isBound() ) {\n\t\t\tthrow new IllegalStateException( \"The parameter at position\" + position + \" has no argument\" );\n\t\t}\n\t\treturn binding.isMultiValued() ? binding.getBindValues() : binding.getBindValue();\n\t}\n\n\tprivate <P> JavaType<P> getJavaType(Class<P> javaType) {\n\t\treturn getTypeConfiguration().getJavaTypeRegistry()\n\t\t\t\t.resolveDescriptor( javaType );\n\t}\n\n\tprivate <P> Type<P> getParamType(Class<P> javaType) {\n\t\tfinal var basicType = getTypeConfiguration().standardBasicTypeForJavaType( javaType );\n\t\treturn basicType != null ? basicType : getSessionFactory().getJpaMetamodel().managedType( javaType );\n\t}\n\n\tprotected QueryParameterBinding<?> locateBinding(Parameter<?> parameter) {\n\t\tif ( parameter instanceof QueryParameterImplementor<?> parameterImplementor ) {\n\t\t\tsession.checkOpen();\n\t\t\treturn getQueryParameterBindings().getBinding( getQueryParameter( parameterImplementor ) );","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractCommonQueryContract.java#L947-L983","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nObject v = query.getParameterValue( 2 ); // ISE: at position2 has no argument\n\n// after\nquery.setParameter( 1, id );\nquery.setParameter( 2, statusOrNull );\nObject v = query.getParameterValue( 2 );","handlingStrategy":"validation","validationCode":"if ( !query.isBound( query.getParameter( position ) ) ) {\n    throw new IllegalStateException( \"Parameter \" + position + \" not bound yet\" );\n}\nObject v = query.getParameterValue( position );","typeGuard":null,"tryCatchPattern":"try {\n    return query.getParameterValue( position );\n} catch ( IllegalStateException e ) {\n    return null;\n}","preventionTips":["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"],"tags":["hibernate","query-parameters","parameter-binding","illegalstate","positional-parameters"],"backgroundTag":"parameter-value-not-bound","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}