{"record":{"id":"7b3876919dd9d2c3","repo":"quarkusio/quarkus","slug":"method-method-of-interface-interface-is-not","errorCode":null,"errorMessage":"Method ${method} of interface ${interface} is not a getter method since it returns void","messagePattern":"Method (.+?) of interface (.+?) is not a getter method since it returns void","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/CustomQueryMethodsAdder.java","lineNumber":519,"sourceCode":"\n        ClassInfo interfaceInfo = index.getClassByName(interfaceName);\n\n        Gizmo gizmo = Gizmo.create(nonBeansClassOutput);\n        gizmo.class_(implName.toString(), implClassCreator -> {\n            implClassCreator.implements_(ClassDesc.of(interfaceName.toString()));\n\n            // Add default constructor\n            implClassCreator.defaultConstructor();\n\n            Map<String, FieldDesc> fields = new HashMap<>(3);\n\n            for (MethodInfo method : interfaceInfo.methods()) {\n                String getterName = method.name();\n                String propertyName = JavaBeanUtil.getPropertyNameFromGetter(getterName);\n\n                Type returnType = method.returnType();\n                if (returnType.kind() == Type.Kind.VOID) {\n                    throw new IllegalArgumentException(\"Method \" + method.name() + \" of interface \" + interfaceName\n                            + \" is not a getter method since it returns void\");\n                }\n                DotName fieldTypeName = getPrimitiveTypeName(returnType.name());\n\n                FieldDesc field = implClassCreator.field(propertyName, ifc -> {\n                    ifc.setType(GenerationUtil.toClassDesc(fieldTypeName.toString()));\n                });\n\n                // create getter (based on the interface)\n                MethodTypeDesc getterMtd = GenerationUtil.toMethodTypeDesc(returnType.name().toString());\n                implClassCreator.method(getterName, mc -> {\n                    mc.setType(getterMtd);\n                    mc.public_();\n                    mc.body(bc -> {\n                        bc.return_(bc.get(mc.this_().field(field)));\n                    });\n                });\n","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/CustomQueryMethodsAdder.java#L501-L537","documentation":"When a custom @Query returns a non-entity type, it must be an interface whose methods are all valid getters returning non-void types; the extension generates a class implementing the interface and maps query columns to fields. A method on the projection interface that returns void cannot be turned into a field, so the build throws this error in generateCustomResultTypes.","triggerScenarios":"Declaring a projection interface with a void-returning method (or a non-getter method returning void, e.g. a setter or default-looking method) used as the return type of a @Query method.","commonSituations":"Including setters or helper void methods in a projection interface; copying a full interface with mutators from a DTO class converted to an interface.","solutions":["Remove the void-returning method from the projection interface","Rename the method to a proper getter (getX()/isX()) with a matching non-void return type","Keep only getter methods in projection interfaces","Move any behavior/logic methods out of the projection interface into a separate utility or default method if truly needed"],"exampleFix":"// before\ninterface UserView {\n  String getName();\n  void setName(String name);\n}\n\n// after\ninterface UserView {\n  String getName();\n}","handlingStrategy":"validation","validationCode":"for (Method m : projection.getMethods()) {\n  if (m.getReturnType() == void.class) throw new AssertionError(m + \" must be a getter\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Projection interfaces: getters only, no void methods","Do not convert mutable DTO classes into projection interfaces wholesale","Keep projections minimal (only selected columns)"],"tags":["quarkus","spring-data-jpa","build-time","projection-interface","getter"],"backgroundTag":"invalid-projection-interface","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}