{"record":{"id":"2337f4e3bba2aef3","repo":"hibernate/hibernate-orm","slug":"no-named-stored-procedure-call-with-given-name","errorCode":null,"errorMessage":"No named stored procedure call with given name '{}'","messagePattern":"No named stored procedure call with given name '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java","lineNumber":2329,"sourceCode":"\t\t\tfinal var query = new NativeQueryImpl<>( sql, true, this );\n\t\t\tapplyQuerySettingsAndHints( query );\n\t\t\treturn query;\n\t\t}\n\t\tcatch ( RuntimeException e ) {\n\t\t\tthrow getExceptionConverter().convert( e );\n\t\t}\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic ProcedureCall getNamedProcedureCall(@Nonnull String name) {\n\t\tcheckOpen();\n\n\t\tfinal var memento =\n\t\t\t\tfactory.getQueryEngine().getNamedObjectRepository()\n\t\t\t\t\t\t.getCallableQueryMemento( name );\n\t\tif ( memento == null ) {\n\t\t\tthrow new IllegalArgumentException( \"No named stored procedure call with given name '\" + name + \"'\" );\n\t\t}\n\t\t@SuppressWarnings(\"UnnecessaryLocalVariable\")\n\t\tfinal var procedureCall = memento.makeProcedureCall( this );\n//\t\tprocedureCall.setComment( \"Named stored procedure call [\" + name + \"]\" );\n\t\treturn procedureCall;\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic ProcedureCall createNamedStoredProcedureQuery(@Nonnull String name) {\n\t\treturn getNamedProcedureCall( name );\n\t}\n\n\n\t// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t// dynamic ProcedureCall support\n\n\t@Override","sourceCodeStart":2311,"sourceCodeEnd":2347,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java#L2311-L2347","documentation":"getNamedProcedureCall()/createNamedStoredProcedureQuery(name) resolves the name against @NamedStoredProcedureQuery registrations in the factory's named-object repository. Nothing registered under that name means the stored-procedure metadata was never deployed, so IllegalArgumentException('No named stored procedure call with given name <name>') is thrown at call creation, before any JDBC work.","triggerScenarios":"Referencing a procedure name that is not registered: @NamedStoredProcedureQuery missing or typo'd, defined on a class outside persistence-unit scanning, XML descriptor mismatch, or the annotation living in a different persistence unit.","commonSituations":"Rename refactors of stored-procedure annotations; new entities with the annotation not listed in an explicit persistence.xml; test persistence units missing the annotated entity; copying service code between microservices without copying the annotation.","solutions":["Verify the exact, case-sensitive name matches @NamedStoredProcedureQuery(name = ...).","Ensure the annotation is on an entity class included in the persistence unit (auto-detection or persistence.xml <class> entry).","If a dynamic call is acceptable, build it with createStoredProcedureCall(procName)/StoredProcedureQuery parameters instead of the named form."],"exampleFix":"// before\nStoredProcedureQuery q = em.createNamedStoredProcedureQuery(\"calcBonus\"); // not registered\n// after\n@Entity\n@NamedStoredProcedureQuery(name = \"calcBonus\", procedureName = \"CALC_BONUS\",\n    parameters = @StoredProcedureParameter(mode = ParameterMode.IN, name = \"empId\", type = Long.class))\npublic class Employee { ... }\nStoredProcedureQuery q = em.createNamedStoredProcedureQuery(\"calcBonus\");","handlingStrategy":"try-catch","validationCode":"// Optional: verify registration at startup (Hibernate SPI)\nNamedObjectRepository named = ((SessionFactoryImplementor) sessionFactory)\n        .getQueryEngine().getNamedObjectRepository();\nif (named.getCallableQueryMemento(procedureName) == null) {\n    throw new IllegalStateException(\n        \"Missing @NamedStoredProcedureQuery '\" + procedureName + \"'\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return em.createNamedStoredProcedureQuery(name);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"No named stored procedure call\")) {\n        // fall back to a dynamic call built from explicit parameters\n        return em.createStoredProcedureQuery(\"CALC_BONUS\", paramTypes());\n    }\n    throw e;\n}","preventionTips":["Define procedure names as constants shared between annotation and caller","Keep @NamedStoredProcedureQuery on entities listed in the persistence unit","Smoke-test named procedure calls at startup in environments with explicit persistence.xml"],"tags":["hibernate","stored-procedure","named-query","jpa","entitymanager"],"backgroundTag":"named-query-not-found","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}