{"record":{"id":"9a4a63019966707e","repo":"quarkusio/quarkus","slug":"couldn-t-find-id-field-of","errorCode":null,"errorMessage":"Couldn't find id field of ","messagePattern":"Couldn't find id field of ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/EntityClassHelper.java","lineNumber":42,"sourceCode":"    public FieldInfo getIdField(String className) {\n        return getIdField(index.getClassByName(DotName.createSimple(className)));\n    }\n\n    private 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 MethodDescriptor getSetter(String className, FieldInfo field) {\n        return getSetter(index.getClassByName(DotName.createSimple(className)), field);\n    }\n\n    private MethodDescriptor getSetter(ClassInfo entityClass, FieldInfo field) {\n        MethodDescriptor setter = getMethod(entityClass, JavaBeanUtil.getSetterName(field.name()), field.type());\n        if (setter != null) {\n            return setter;\n        }\n        return MethodDescriptor.ofMethod(entityClass.toString(),\n                EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX + field.name(), void.class, field.type().name().toString());\n    }\n\n    private MethodDescriptor getMethod(ClassInfo entityClass, String name, Type... parameters) {\n        if (entityClass == null) {\n            return null;","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/EntityClassHelper.java#L24-L60","documentation":"The REST Data Panache deployment must know which field is the entity's identifier to generate resource methods. It walks the class hierarchy looking for a field named 'id' and throws IllegalArgumentException when none is found.","triggerScenarios":"An entity referenced by a Panache REST Data resource has no field named id in the class or any indexed superclass, so getIdField exhausts the hierarchy and throws.","commonSituations":"Custom entity with a differently named key field (e.g. userId, uuid); missing @Id annotation; entity superclasses not present in the Jandex index.","solutions":["Declare an explicit identifier field named id in the entity (e.g. @Id public ObjectId id;)","If the key must be named differently, rename it to id or use a non-Panache REST data approach","Ensure the entity class and its superclasses are in the Jandex index (add a Jandex index if in an external jar)"],"exampleFix":"// before\npublic class Customer {\n    public String customerId;\n}\n// after\npublic class Customer {\n    @Id\n    public ObjectId id;\n}","handlingStrategy":"validation","validationCode":"boolean hasId = Arrays.stream(Customer.class.getFields()).anyMatch(f -> f.getName().equals(\"id\"));\nif (!hasId) throw new IllegalStateException(\"Entity must expose an 'id' field for REST Data Panache\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always name the identifier field 'id' in entities used by REST Data Panache","Annotate it with @Id","Keep entities in the application index (not an unindexed external jar)"],"tags":["quarkus","panache","rest-data","jandex","entity-id"],"backgroundTag":"missing-id-field","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}