{"record":{"id":"1dbc45984df35915","repo":"quarkusio/quarkus","slug":"the-number-of-parameters-of-method-method-of-re","errorCode":null,"errorMessage":"The number of parameters of method ${method} of Repository ${repository} does not match the number of parameter needed (inferred from the method name)","messagePattern":"The number of parameters of method (.+?) of Repository (.+?) does not match the number of parameter needed \\(inferred from the method name\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/DerivedMethodsAdder.java","lineNumber":141,"sourceCode":"                                + \"has invalid parameters - only a single parameter of type\" + DotNames.SPRING_DATA_SORT\n                                + \" can be specified\");\n                    }\n                    sortParameterIndex = i;\n                } else if (isDynamicProjectionParameter(paramType, method)) {\n                    if (dynamicProjectionParameterIndex != null) {\n                        throw new IllegalArgumentException(\"Method \" + method.name() + \" of Repository \" + repositoryClassInfo\n                                + \"has invalid parameters - only a single dynamic projection parameter of type \"\n                                + DotNames.CLASS + \" can be specified\");\n                    }\n                    dynamicProjectionParameterIndex = i;\n                } else {\n                    queryParameterIndexes.add(i);\n                }\n            }\n\n            MethodNameParser.Result parseResult = methodNameParser.parse(method);\n            if (parseResult.getParamCount() != queryParameterIndexes.size()) {\n                throw new IllegalArgumentException(\"The number of parameters of method \" + method.name() + \" of Repository \"\n                        + repositoryClassInfo\n                        + \" does not match the number of parameter needed (inferred from the method name)\");\n            }\n\n            // Need effectively final copies for use in lambdas\n            final Integer finalPageableParameterIndex = pageableParameterIndex;\n            final Integer finalSortParameterIndex = sortParameterIndex;\n            final Integer finalDynamicProjectionParameterIndex = dynamicProjectionParameterIndex;\n            final Type finalReturnType = returnType;\n\n            MethodTypeDesc mtd = GenerationUtil.toMethodTypeDesc(returnType.name().toString(), parameterTypesStr);\n            classCreator.method(method.name(), mc -> {\n                mc.setType(mtd);\n\n                // Add @Transactional for delete queries before calling body()\n                if (parseResult.getQueryType() == MethodNameParser.QueryType.DELETE) {\n                    mc.addAnnotation(Transactional.class);\n                }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/DerivedMethodsAdder.java#L123-L159","documentation":"For derived query methods, the extension parses the method name (e.g. findByLastNameAndAge) to determine how many query parameters are required. If the actual number of non-Pageable/Sort/projection parameters in the signature differs from the count implied by the method name, the build fails with this error in DerivedMethodsAdder.add.","triggerScenarios":"Method name predicates and parameter list disagree, e.g. findByName(String first, String last) or findByNameAndAge(String name) — MethodNameParser.Result.getParamCount() != queryParameterIndexes.size().","commonSituations":"Renaming a method to add 'AndAge' without adding the parameter; adding a parameter without updating the name; typos in property names in the method name; using Optional/wrapper mismatches that alter counting is NOT this, but plain count mismatch is.","solutions":["Make the method name predicate count match the parameter count (e.g. rename findByName to findByNameAndAge or drop the extra parameter)","Add the missing parameter for each condition in the method name","Remove extra parameters or the corresponding condition keyword from the name","Convert the method to an explicit @Query if the name-based derivation is too fragile"],"exampleFix":"// before\nList<User> findByNameAndAge(String name);\n\n// after\nList<User> findByNameAndAge(String name, Integer age);","handlingStrategy":"validation","validationCode":"// count condition keywords in the derived name (And/Or) and ensure params match\nint expected = countConditions(\"findByNameAndAge\"); // 2","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add/remove parameters when renaming derived methods","Count And/Or conditions against the parameter list before saving","Switch to explicit @Query when the derived name gets complex"],"tags":["quarkus","spring-data-jpa","build-time","derived-query","parameter-count"],"backgroundTag":"derived-method-parameter-count-mismatch","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}