{"record":{"id":"e7c11f7843f4b69c","repo":"quarkusio/quarkus","slug":"distinct-is-not-yet-supported-offending-method-is","errorCode":null,"errorMessage":"Distinct is not yet supported. Offending method is ${repositoryMethodDescription}.","messagePattern":"Distinct is not yet supported\\. Offending method is (.+?)\\.","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":132,"sourceCode":"                                + repositoryMethodDescription + \".\");\n            }\n            try {\n                String topCountStr = methodName.substring(minFirstOrTopIndex, byIndex)\n                        .replace(\"Top\", \"\").replace(\"First\", \"\");\n                if (topCountStr.isEmpty()) {\n                    topCount = 1;\n                } else {\n                    topCount = Integer.valueOf(topCountStr);\n                }\n            } catch (Exception e) {\n                throw new UnableToParseMethodException(\n                        \"Unable to parse query with limiting results clause. Offending method is \"\n                                + repositoryMethodDescription + \".\");\n            }\n        }\n\n        if (methodName.substring(0, byIndex).contains(\"Distinct\")) {\n            throw new UnableToParseMethodException(\n                    \"Distinct is not yet supported. Offending method is \" + repositoryMethodDescription + \".\");\n        }\n\n        // handle 'AllIgnoreCase'\n        String afterByPart = methodName.substring(byIndex + 2);\n        boolean allIgnoreCase = false;\n        if (afterByPart.contains(ALL_IGNORE_CASE)) {\n            allIgnoreCase = true;\n            afterByPart = afterByPart.replace(ALL_IGNORE_CASE, \"\");\n        }\n\n        // handle the 'OrderBy' clause which is assumed to be at the end of the query\n        Sort sort = null;\n        if (containsLogicOperator(afterByPart, ORDER_BY)) {\n            int orderByIndex = afterByPart.indexOf(ORDER_BY);\n            if (orderByIndex + ORDER_BY.length() == afterByPart.length()) {\n                throw new UnableToParseMethodException(\n                        \"A field must by supplied after 'OrderBy' . Offending method is \" + repositoryMethodDescription + \".\");","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/MethodNameParser.java#L114-L150","documentation":"Quarkus Spring Data JPA's derived query parser rejects repository method names containing the 'Distinct' keyword because distinct projection is not implemented in the method-name-to-JPQL translation. The build fails at augmentation time with UnableToParseMethodException naming the offending method.","triggerScenarios":"Declaring a derived repository method whose name contains 'Distinct' between the query prefix and 'By' (e.g. findDistinctByEmailByLastname(String lastname), countDistinctUsersBy...) on a Spring Data JPA repository processed by Quarkus.","commonSituations":"Porting a Spring Boot app to Quarkus where derived queries used Distinct to deduplicate joined or one-to-many results; copying Spring Data query method names verbatim.","solutions":["Remove 'Distinct' from the method name and use a @Query annotation with 'SELECT DISTINCT ...' in JPQL instead","Restructure the query so duplicates cannot occur (e.g. query the parent entity only, or use a DTO projection via @Query)","If dedup is only needed for existence checks, use exists...By or a returning-limiting variant without Distinct"],"exampleFix":"// before\nList<User> findDistinctByEmailByLastname(String lastname);\n// after\n@Query(\"SELECT DISTINCT u.email FROM User u WHERE u.lastname = :ln\")\nList<String> findEmailsByLastname(@Param(\"ln\") String lastname);","handlingStrategy":"validation","validationCode":"// before compiling, grep your repositories:\n// grep -rnE 'findDistinct|countDistinct|readDistinct|getDistinct|deleteDistinct' src/main/java","typeGuard":null,"tryCatchPattern":"// Build-time failure; catch during tests:\ntry {\n    // augmentation happens at build; instead validate in a unit test\n    // by invoking the parser on the method name\n    parser.parse(methodName);\n} catch (UnableToParseMethodException e) {\n    throw new IllegalStateException(\"Use @Query for Distinct: \" + e.getMessage());\n}","preventionTips":["Avoid 'Distinct' in derived method names; prefer explicit @Query JPQL","Search the codebase for 'Distinct' in repository interfaces when migrating to Quarkus","Write a build/CI test that instantiates all repositories (QuarkusTest) to catch parse failures early"],"tags":["jpa","spring-data","derived-query","build-time"],"backgroundTag":"unsupported-derived-query-method","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"}