{"record":{"id":"4c5cbf72685ce91d","repo":"quarkusio/quarkus","slug":"couldn-t-find-id-field-of-classinfo-4c5cbf","errorCode":null,"errorMessage":"Couldn't find id field of ${classInfo}","messagePattern":"Couldn't find id field of (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-data-rest/deployment/src/main/java/io/quarkus/spring/data/rest/deployment/EntityClassHelper.java","lineNumber":54,"sourceCode":"    public FieldInfo getIdField(String className) {\n        return getIdField(index.getClassByName(DotName.createSimple(className)));\n    }\n\n    public FieldInfo getIdField(ClassInfo classInfo) {\n        ClassInfo tmpClassInfo = classInfo;\n        while (tmpClassInfo != null) {\n            for (FieldInfo field : tmpClassInfo.fields()) {\n                if (field.hasAnnotation(DotName.createSimple(Id.class.getName()))) {\n                    return field;\n                }\n            }\n            if (tmpClassInfo.superName() != null) {\n                tmpClassInfo = index.getClassByName(tmpClassInfo.superName());\n            } else {\n                tmpClassInfo = null;\n            }\n        }\n        throw new IllegalArgumentException(\"Couldn't find id field of \" + classInfo);\n    }\n\n    public MethodDesc getSetter(String className, FieldInfo field) {\n        return getSetter(index.getClassByName(DotName.createSimple(className)), field);\n    }\n\n    public MethodDesc getSetter(ClassInfo entityClass, FieldInfo field) {\n        MethodDesc setter = getMethod(entityClass, JavaBeanUtil.getSetterName(field.name()), field.type());\n        if (setter != null) {\n            return setter;\n        }\n        return ClassMethodDesc.of(\n                ClassDesc.of(entityClass.toString()),\n                EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX + field.name(),\n                CD_void,\n                Jandex2Gizmo.classDescOf(field.type()));\n    }\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-rest/deployment/src/main/java/io/quarkus/spring/data/rest/deployment/EntityClassHelper.java#L36-L72","documentation":"EntityClassHelper.getIdField walks the entity's class hierarchy through the Jandex index looking for a field that is the entity id. When no id field is found before reaching the top of the hierarchy, the extension fails the build with this IllegalArgumentException. Spring Data REST needs the id to generate endpoint paths and resource handling.","triggerScenarios":"A repository projected into a Spring Data REST resource whose entity lacks a field annotated with @Id/@EmbeddedId (including inherited fields); the id is exposed only via a method the field-walk doesn't recognize, or the id comes from an unindexed superclass chain that resolves to null.","commonSituations":"Entities using @IdClass without an actual @Id field; id defined via getter-only mapping the helper doesn't scan; id in a superclass from a library where index traversal stops (superName null or class missing).","solutions":["Add an explicit @Id-annotated field to the entity (or its superclass within the indexed hierarchy)","Use @EmbeddedId on a field for composite keys so the field walk finds it","Verify the superclass holding the id is present in the index (quarkus.index-dependency for its JAR)","Inspect the entity for typos in the annotation import (must be jakarta.persistence.Id)"],"exampleFix":"// before\n@Entity\npublic class Item {\n    @EmbeddedId private ItemKey key; // key class not embeddable/indexed\n}\n\n// after\n@Entity\npublic class Item {\n    @EmbeddedId\n    private ItemKey key; // @Embeddable ItemKey, in indexed module\n}","handlingStrategy":"validation","validationCode":"// Unit test guard:\nboolean hasId = java.util.Arrays.stream(Item.class.getDeclaredFields())\n    .anyMatch(f -> f.isAnnotationPresent(jakarta.persistence.Id.class)\n        || f.isAnnotationPresent(jakarta.persistence.EmbeddedId.class));\nif (!hasId) throw new IllegalStateException(\"Entity exposed via REST needs an id field\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every REST-exposed entity an explicit @Id or @EmbeddedId field","Prefer field-level JPA annotations over getter-only mappings","Ensure id-bearing superclasses are indexed","Keep composite keys in @Embeddable classes within indexed modules"],"tags":["quarkus","spring-data-rest","jpa","entity-mapping","build-time"],"backgroundTag":"missing-jpa-id-annotation","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"}