{"record":{"id":"26b7ee240f463be3","repo":"quarkusio/quarkus","slug":"method-of-repository-repository-is-meant-to-26b7ee","errorCode":null,"errorMessage":"${method} of Repository ${repository} is meant to be an exists query and can therefore only have a boolean return type","messagePattern":"(.+?) of Repository (.+?) is meant to be an exists query and can therefore only have a boolean return type","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":317,"sourceCode":"                            throw new IllegalArgumentException(\n                                    method.name() + \" of Repository \" + repositoryClassInfo\n                                            + \" is meant to be a count query and therefore doesn't \" +\n                                            \"support Pageable and Sort method parameters\");\n                        }\n\n                        // call JpaOperations.count()\n                        Expr count = bc.invokeVirtual(\n                                MethodDesc.of(AbstractManagedJpaOperations.class, \"count\", long.class,\n                                        Class.class, String.class, Object[].class),\n                                ops, entityClass,\n                                Const.of(parseResult.getQuery()), paramsArray);\n\n                        handleLongReturnValue(bc, count, returnType.name());\n\n                    } else if (parseResult.getQueryType() == MethodNameParser.QueryType.EXISTS) {\n                        if (!DotNames.PRIMITIVE_BOOLEAN.equals(returnType.name())\n                                && !DotNames.BOOLEAN.equals(returnType.name())) {\n                            throw new IllegalArgumentException(\n                                    method.name() + \" of Repository \" + repositoryClassInfo\n                                            + \" is meant to be an exists query and can therefore only have a boolean return type\");\n                        }\n                        if ((finalSortParameterIndex != null) || finalPageableParameterIndex != null) {\n                            throw new IllegalArgumentException(\n                                    method.name() + \" of Repository \" + repositoryClassInfo\n                                            + \" is meant to be a count query and therefore doesn't \" +\n                                            \"support Pageable and Sort method parameters\");\n                        }\n\n                        // call JpaOperations.exists()\n                        Expr exists = bc.invokeVirtual(\n                                MethodDesc.of(AbstractManagedJpaOperations.class, \"exists\", boolean.class,\n                                        Class.class, String.class, Object[].class),\n                                ops, entityClass,\n                                Const.of(parseResult.getQuery()), paramsArray);\n\n                        handleBooleanReturnValue(bc, exists, returnType.name());","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/DerivedMethodsAdder.java#L299-L335","documentation":"Derived methods named existsBy... are generated as existence checks whose only meaningful result is a boolean. The spring-data-jpa extension requires the return type to be boolean or java.lang.Boolean; any other return type fails the build with this IllegalArgumentException.","triggerScenarios":"Declaring e.g. int existsByEmail(String email) or Long existsById(Long id) — an EXISTS query type whose returnType.name() is neither DotNames.PRIMITIVE_BOOLEAN nor DotNames.BOOLEAN.","commonSituations":"Mapping boolean results to int 0/1 out of habit from SQL or another ORM; reusing a find method's signature after renaming it to existsBy; Optional-based return types mistakenly used for existence checks.","solutions":["Change the return type to primitive boolean","Or use java.lang.Boolean when a boxed type is needed","If a different shape is required, use @Query with an appropriate select instead of the existsBy prefix"],"exampleFix":"// before\nint existsByEmail(String email);\n\n// after\nboolean existsByEmail(String email);","handlingStrategy":"validation","validationCode":"// Ensure every existsBy method returns boolean or Boolean\nfor (Method m : PersonRepository.class.getDeclaredMethods()) {\n    if (m.getName().startsWith(\"existsBy\")) {\n        Class<?> r = m.getReturnType();\n        if (r != boolean.class && r != Boolean.class)\n            throw new IllegalStateException(m.getName() + \" must return boolean/Boolean, got \" + r);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare existsBy methods as returning primitive boolean","Do not map SQL-style 0/1 ints into repository signatures","Use Optional<T> only for findBy, never for existsBy"],"tags":["spring-data","jpa","quarkus","derived-query","build-time"],"backgroundTag":"invalid-exists-return-type","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"}