{"record":{"id":"6d974c5d2c29b8a2","repo":"quarkusio/quarkus","slug":"couldn-t-find-id-field-of-classinfo","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/panache/hibernate-orm-rest-data-panache/deployment/src/main/java/io/quarkus/hibernate/orm/rest/data/panache/deployment/EntityClassHelper.java","lineNumber":43,"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(JAVAX_PERSISTENCE_ID)) {\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":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/panache/hibernate-orm-rest-data-panache/deployment/src/main/java/io/quarkus/hibernate/orm/rest/data/panache/deployment/EntityClassHelper.java#L25-L61","documentation":"During REST Data Panache build-time indexing, the extension walks the entity class hierarchy (via Jandex) looking for the ID field. If the walk exhausts the hierarchy without finding a field named 'id', it throws IllegalArgumentException. This means the resource's entity type has no recognizable identifier.","triggerScenarios":"Registering a Panache REST Data resource interface (e.g. implementing PanacheEntityResource or a custom repository interface) whose bound entity class has no 'id' field and whose superclasses contain none either.","commonSituations":"Entity with a custom primary key field name (e.g. @Id Long userId) that Panache REST Data cannot detect; entity not annotated with @Id at all; stale/incomplete Jandex index of an external entity class.","solutions":["Add an @Id field named 'id' to the entity class","If the key must have another name, check you are using the correct resource interface matching the entity","Rebuild so Jandex indexes the entity module (add Jandex index via jandex-maven-plugin for dependency jars)","Verify the entity is on the application's indexed classpath (not in an unindexed external jar)"],"exampleFix":"// before\nclass Customer extends SomeBaseEntity {\n    @Id\n    private Long customerNumber;\n}\n// after\nclass Customer extends SomeBaseEntity {\n    @Id\n    private Long id; // rename or add an 'id' field\n}","handlingStrategy":"validation","validationCode":"if (!java.lang.reflect.Modifier.isAbstract(entityClass.getSuperclass().getName()) ) {\n    boolean hasId = java.util.Arrays.stream(entityClass.getDeclaredFields())\n        .anyMatch(f -> f.isAnnotationPresent(jakarta.persistence.Id.class)\n                   || f.isAnnotationPresent(jakarta.persistence.EmbeddedId.class));\n    if (!hasId) throw new IllegalStateException(entityClass + \" has no @Id field\");\n}","typeGuard":"static boolean hasPanacheId(Class<?> c) {\n    for (Class<?> k = c; k != null && k != Object.class; k = k.getSuperclass()) {\n        for (Field f : k.getDeclaredFields())\n            if (f.isAnnotationPresent(jakarta.persistence.Id.class)) return true;\n    }\n    return false;\n}","tryCatchPattern":null,"preventionTips":["Always give entities an @Id field; prefer the conventional name 'id'","Run a quick build (mvn -Dquickly) before committing new entities","Ensure dependent jars expose Jandex indexes (jandex-maven-plugin or META-INF/jandex.idx)"],"tags":["quarkus","panache","rest-data","build-time","jandex"],"backgroundTag":"missing-entity-id-field","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"}