{"record":{"id":"a60c717e555ea6be","repo":"hibernate/hibernate-orm","slug":"no-function-registered-under-the-name","errorCode":null,"errorMessage":"No function registered under the name '{}'","messagePattern":"No function registered under the name '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/function/DynamicDispatchFunction.java","lineNumber":45,"sourceCode":" */\npublic class DynamicDispatchFunction implements SqmFunctionDescriptor, ArgumentsValidator {\n\tprivate final SqmFunctionRegistry functionRegistry;\n\tprivate final String[] functionNames;\n\tprivate final FunctionKind functionKind;\n\n\tpublic DynamicDispatchFunction(SqmFunctionRegistry functionRegistry, String... functionNames) {\n\t\tthis.functionRegistry = functionRegistry;\n\t\tthis.functionNames = functionNames;\n\t\tthis.functionKind = functionKind( functionRegistry, functionNames );\n\t}\n\n\tprivate static FunctionKind functionKind(SqmFunctionRegistry functionRegistry, String[] functionNames) {\n\t\tFunctionKind functionKind = null;\n\t\t// Sanity check\n\t\tfor ( String overload : functionNames ) {\n\t\t\tfinal var functionDescriptor = functionRegistry.findFunctionDescriptor( overload );\n\t\t\tif ( functionDescriptor == null ) {\n\t\t\t\tthrow new IllegalArgumentException( \"No function registered under the name '\" + overload + \"'\" );\n\t\t\t}\n\t\t\tif ( functionKind == null ) {\n\t\t\t\tfunctionKind = functionDescriptor.getFunctionKind();\n\t\t\t}\n\t\t\telse if ( functionKind != functionDescriptor.getFunctionKind() ) {\n\t\t\t\tthrow new IllegalArgumentException( \"Function has function kind \" + functionDescriptor.getFunctionKind()\n\t\t\t\t\t\t\t\t\t\t\t\t\t+ \", but other overloads have \" + functionKind\n\t\t\t\t\t\t\t\t\t\t\t\t\t+ \". An overloaded function needs a single function kind.\" );\n\t\t\t}\n\t\t}\n\t\treturn functionKind;\n\t}\n\n\t@Override\n\tpublic FunctionKind getFunctionKind() {\n\t\treturn functionKind;\n\t}\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/function/DynamicDispatchFunction.java#L27-L63","documentation":"DynamicDispatchFunction is the descriptor Hibernate registers for overloaded function names; at construction it sanity-checks that every overload name is already present in the SqmFunctionRegistry. If one of the names passed to its constructor is not registered, it throws this IllegalArgumentException immediately, catching registration-order bugs.","triggerScenarios":"Programmatic registration like functionRegistry.registerFunction(...)/registerOverload(...) wiring a DynamicDispatchFunction('f','f_a','f_b') before 'f_b' exists in the registry; usually only hit by dialect authors or apps customizing SqmFunctionRegistry at bootstrap.","commonSituations":"Custom dialect development registering overloads in the wrong order; copying registration snippets between dialects and dropping one registerUnaryBinaryFunction/... call; bootstrap-time unit tests that build a partial registry.","solutions":["Register every underlying overload descriptor before constructing the DynamicDispatchFunction for it","Check the exact names (case, underscores) passed as functionNames against the keys you registered","If an overload was intentionally removed, also remove its name from the DynamicDispatchFunction constructor call"],"exampleFix":"// before\nregistry.registerFunction(\"myfunc\", new DynamicDispatchFunction(registry, \"myfunc_int\", \"myfunc_str\"));\nregistry.registerUnaryBinaryFunction... // myfunc_str registered too late\n\n// after\nregistry.registerBinaryFunction(\"myfunc_int\", intDescriptor);\nregistry.registerBinaryFunction(\"myfunc_str\", strDescriptor);\nregistry.registerFunction(\"myfunc\", new DynamicDispatchFunction(registry, \"myfunc_int\", \"myfunc_str\"));","handlingStrategy":"validation","validationCode":"for (String name : functionNames) {\n    if (registry.findFunctionDescriptor(name) == null) {\n        throw new IllegalStateException(\"Register '\" + name + \"' before creating DynamicDispatchFunction\");\n    }\n}\nnew DynamicDispatchFunction(registry, functionNames);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register all overloads first, then the dispatch function — make it a build-order convention","Cover registry wiring with a bootstrap unit test that constructs the full dialect","Log registered function names once at startup for diffing when registration changes"],"tags":["hibernate","function-registry","overloading","bootstrap","custom-dialect"],"backgroundTag":"function-not-registered","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}