{"record":{"id":"4aeb3e829701bf49","repo":"quarkusio/quarkus","slug":"method-repositorymethoddescription-cannot-be-pa-4aeb3e","errorCode":null,"errorMessage":"Method ${repositoryMethodDescription} cannot be parsed as there is no proper 'By' clause in the name.","messagePattern":"Method (.+?) cannot be parsed as there is no proper 'By' clause in the name\\.","errorType":"exception","errorClass":"UnableToParseMethodException","httpStatus":null,"severity":"error","filePath":"extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/MethodNameParser.java","lineNumber":101,"sourceCode":"\n    public Result parse(MethodInfo methodInfo) {\n        String methodName = methodInfo.name();\n        ClassInfo repositoryClassInfo = methodInfo.declaringClass();\n        String repositoryMethodDescription = \"'\" + methodName + \"' of repository '\" + repositoryClassInfo + \"'\";\n        QueryType queryType = getType(methodName);\n        String entityAlias = getEntityName().toLowerCase();\n        // The SELECT clause is necessary after https://hibernate.atlassian.net/browse/HHH-18584\n        String selectClause = queryType == QueryType.SELECT ? \"SELECT \" + entityAlias + \" \" : \"\";\n        String fromClause = \"FROM \" + getEntityName() + \" AS \" + entityAlias;\n        String joinClause = \"\";\n        if (queryType == null) {\n            throw new UnableToParseMethodException(\"Method \" + repositoryMethodDescription\n                    + \" cannot be parsed. Did you forget to annotate the method with '@Query'?\");\n        }\n\n        int byIndex = methodName.indexOf(\"By\");\n        if ((byIndex == -1) || (byIndex + 2 >= methodName.length())) {\n            throw new UnableToParseMethodException(\"Method \" + repositoryMethodDescription\n                    + \" cannot be parsed as there is no proper 'By' clause in the name.\");\n        }\n\n        // handle 'Top' and 'First'\n        Integer topCount = null;\n        int minFirstOrTopIndex = Math.min(indexOfOrMaxValue(methodName, \"First\"), indexOfOrMaxValue(methodName, \"Top\"));\n        // 'First' and 'Top' could be part of a field name, so we only consider them as part of a top query\n        // if they are found before 'By'\n        if (minFirstOrTopIndex < byIndex) {\n            if (queryType != QueryType.SELECT) {\n                throw new UnableToParseMethodException(\n                        \"When 'Top' or 'First' is specified, the query must be a find query. Offending method is \"\n                                + repositoryMethodDescription + \".\");\n            }\n            try {\n                String topCountStr = methodName.substring(minFirstOrTopIndex, byIndex)\n                        .replace(\"Top\", \"\").replace(\"First\", \"\");\n                if (topCountStr.isEmpty()) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/MethodNameParser.java#L83-L119","documentation":"MethodNameParser requires a 'By' separator followed by criteria to split the method name into predicate parts. When the derived-query method name contains no 'By' (or 'By' is the last token), parsing fails with UnableToParseMethodException.","triggerScenarios":"Methods like `List<User> findAll();` in a Spring-style derived query repo (not supported here without @Query), or `findByNameBy` / `findByNameBy` with 'By' at the end — byIndex == -1 or byIndex+2 >= methodName.length().","commonSituations":"findAll()/getAll() declared expecting Spring Data's built-in handling; typo leaving a dangling 'By' (e.g. `findBy`); generated method names truncated.","solutions":["Add criteria after 'By', e.g. findAll -> findAllBy... or better use @Query for unfiltered selects","For no-filter queries use @Query(\"FROM User\") or count/delete variants with explicit @Query","Remove the trailing dangling 'By' from the method name","Implement the method in a custom repository fragment (Entity_Manager delegate) instead"],"exampleFix":"// before\nList<User> findAll();\n// after\n@Query(\"FROM User\")\nList<User> findAll();","handlingStrategy":"validation","validationCode":"// method name must contain 'By' with criteria after it\nboolean ok = methodName.contains(\"By\")\n          && methodName.indexOf(\"By\") + 2 < methodName.length();","typeGuard":null,"tryCatchPattern":"// Build-time failure; fix by adding criteria or @Query:\n// @Query(\"FROM User\") List<User> findAll();","preventionTips":["Don't expect findAll()/getAll() to be derived — use @Query or a base repository","Never leave a dangling 'By' at the end of a method name","Lint repo interfaces for the By-clause pattern"],"tags":["spring-data-jpa","build-time","derived-query","method-naming"],"backgroundTag":"unparseable-repository-method","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}