{"record":{"id":"d5f93de3c196bbd7","repo":"hibernate/hibernate-orm","slug":"parameter-parameter-is-not-registered-wi","errorCode":null,"errorMessage":"Parameter [\" + parameter + \"] is not registered with this procedure call","messagePattern":"Parameter \\[\" \\+ parameter \\+ \"\\] is not registered with this procedure call","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/procedure/internal/OutputsImpl.java","lineNumber":124,"sourceCode":"\t\t\t\tthrow convert( e, \"Error calling CallableStatement.getUpdateCount\" );\n\t\t\t}\n\t\t}\n\n\t\treturn buildCurrentReturnState( isResultSet, updateCount );\n\t}\n\n\tprotected CurrentReturnState buildCurrentReturnState(boolean isResultSet, int updateCount) {\n\t\treturn new CurrentReturnState( this, isResultSet, updateCount );\n\t}\n\n\t@Override\n\tpublic <T> T getOutputParameterValue(ProcedureParameter<T> parameter) {\n\t\tif ( parameter.getMode() == ParameterMode.IN ) {\n\t\t\tthrow new ParameterMisuseException( \"IN parameter not valid for output extraction\" );\n\t\t}\n\t\tfinal var registration = parameterRegistrations.get( parameter );\n\t\tif ( registration == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Parameter [\" + parameter + \"] is not registered with this procedure call\" );\n\t\t}\n\t\ttry {\n\t\t\tif ( registration.getParameterMode() == ParameterMode.REF_CURSOR ) {\n\t\t\t\t//noinspection unchecked\n\t\t\t\treturn (T) registration.getRefCursorExtractor().extractResultSet(\n\t\t\t\t\t\tjdbcStatement,\n\t\t\t\t\t\tprocedureCall.getSession()\n\t\t\t\t);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//noinspection unchecked\n\t\t\t\treturn (T) registration.getParameterExtractor().extractValue(\n\t\t\t\t\t\tjdbcStatement,\n\t\t\t\t\t\tparameter.getPosition() == null,\n\t\t\t\t\t\tprocedureCall.getSession()\n\t\t\t\t);\n\t\t\t}\n\t\t}","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/procedure/internal/OutputsImpl.java#L106-L142","documentation":"getOutputParameterValue looks the passed parameter up in this call's parameterRegistrations map, keyed by the exact ProcedureParameter instance. If the argument was never registered on this ProcedureCall — typically a handle obtained from a different ProcedureCall instance — the lookup returns null and Hibernate throws IllegalArgumentException('Parameter [...] is not registered with this procedure call').","triggerScenarios":"Passing a ProcedureParameter obtained from another StoredProcedureQuery/ProcedureCall (e.g. a cached or statically held parameter object); extracting with a parameter created before this call's registrations were made.","commonSituations":"Caching ProcedureParameter objects in fields/maps and reusing them across calls or sessions; copy-pasted parameter handling shared between two procedures; integration code that builds the query in one layer and extracts outputs in another with mixed instances.","solutions":["Use the name/position overloads — getOutputParameterValue(String name) / getOutputParameterValue(int position) — which resolve against this call's own parameter metadata.","Always obtain the handle from the same instance you execute: proc.getParameter(name).","Never share ProcedureParameter instances across ProcedureCall instances; they are per-call state."],"exampleFix":"// before\nStoredProcedureQuery other = em.createStoredProcedureQuery(\"pkg.p1\");\nParameter<Integer> stale = other.getParameter(\"out1\");\nObject v = proc.getOutputParameterValue(stale); // not registered on proc\n\n// after\nObject v = proc.getOutputParameterValue(\"out1\"); // resolves via this call's metadata","handlingStrategy":"validation","validationCode":"// resolve the parameter against THIS call before extracting\nboolean registered = proc.getParameters().stream()\n        .anyMatch( p -> Objects.equals( p.getName(), name ) );\nif ( !registered ) {\n    throw new IllegalArgumentException( name + \" not registered on this procedure call\" );\n}\nObject value = proc.getOutputParameterValue( name ); // name/position overload resolves internally","typeGuard":null,"tryCatchPattern":"try {\n    Object v = proc.getOutputParameterValue( parameter );\n} catch (IllegalArgumentException e) {\n    if ( e.getMessage() != null && e.getMessage().contains( \"not registered\" ) ) {\n        Object v = proc.getOutputParameterValue( parameter.getName() ); // re-resolve by name\n    } else { throw e; }\n}","preventionTips":["Prefer the name/position overloads of getOutputParameterValue over passing parameter objects.","Never cache or share ProcedureParameter instances across ProcedureCall instances.","Create, register, execute, and extract on the same ProcedureCall instance in one flow."],"tags":["hibernate","stored-procedure","parameter-registration","output-parameter"],"backgroundTag":"unregistered-query-parameter","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}