{"record":{"id":"8f94d6fd31377f40","repo":"quarkusio/quarkus","slug":"method-of-repository-repository-is-meant-to-8f94d6","errorCode":null,"errorMessage":"${method} of Repository ${repository} is meant to be a delete query and can therefore only have a void or long return type","messagePattern":"(.+?) of Repository (.+?) is meant to be a delete query and can therefore only have a void or long 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":340,"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.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());\n\n                    } else if (parseResult.getQueryType() == MethodNameParser.QueryType.DELETE) {\n                        if (!DotNames.PRIMITIVE_LONG.equals(returnType.name()) && !DotNames.LONG.equals(returnType.name())\n                                && !DotNames.VOID.equals(returnType.name())) {\n                            throw new IllegalArgumentException(\n                                    method.name() + \" of Repository \" + repositoryClassInfo\n                                            + \" is meant to be a delete query and can therefore only have a void or long 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 delete query and therefore doesn't \" +\n                                            \"support Pageable and Sort method parameters\");\n                        }\n\n                        AnnotationInstance modifyingAnnotation = method.annotation(DotNames.SPRING_DATA_MODIFYING);\n                        handleFlushAutomatically(modifyingAnnotation, bc, entityClass);\n\n                        // call JpaOperations.delete()\n                        Expr delete = bc.invokeStatic(\n                                MethodDesc.of(AdditionalJpaOperations.class, \"deleteWithCascade\",\n                                        long.class, AbstractManagedJpaOperations.class, Class.class, String.class,\n                                        Object[].class),","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/DerivedMethodsAdder.java#L322-L358","documentation":"Derived methods named deleteBy... are generated as bulk delete operations. The spring-data-jpa extension allows them to return only void or a long/Long (the number of removed rows); any other return type fails the build with this IllegalArgumentException.","triggerScenarios":"Declaring e.g. int deleteByExpired(boolean expired) or List<Person> deleteByStatus(String status) — a DELETE query type whose returnType.name() is not PRIMITIVE_LONG, LONG, or VOID.","commonSituations":"Using int for affected-row counts out of JDBC habit; expecting deleteBy to return the deleted entities (a Spring Data derived-query behavior Quarkus's generator does not support here); changing a findBy to deleteBy without changing the return type.","solutions":["Change the return type to void if the count is not needed","Or use long (or Long) to receive the number of deleted rows","To obtain the deleted entities first, select them with a findBy, then delete them explicitly"],"exampleFix":"// before\nint deleteByExpired(boolean expired);\n\n// after\nlong deleteByExpired(boolean expired);","handlingStrategy":"validation","validationCode":"// Ensure deleteBy methods return void, long or Long\nfor (Method m : PersonRepository.class.getDeclaredMethods()) {\n    if (m.getName().startsWith(\"deleteBy\")) {\n        Class<?> r = m.getReturnType();\n        if (r != void.class && r != long.class && r != Long.class)\n            throw new IllegalStateException(m.getName() + \" must return void/long/Long, got \" + r);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Return long when the removed count matters, otherwise void","Do not expect deleteBy to return deleted entities — load then delete instead","Enforce with an ArchUnit rule over repository packages"],"tags":["spring-data","jpa","quarkus","derived-query","build-time"],"backgroundTag":"invalid-delete-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"}