{"record":{"id":"c1f1296620edd7c2","repo":"NationalSecurityAgency/ghidra","slug":"cannot-find-column-for-dbannotatedcolumn-on","errorCode":null,"errorMessage":"Cannot find column '{}' for @DBAnnotatedColumn on {}","messagePattern":"Cannot find column '(.+?)' for @DBAnnotatedColumn on (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBCachedObjectStoreFactory.java","lineNumber":1186,"sourceCode":"\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint mod = f.getModifiers();\n\t\t\t\tif (!Modifier.isStatic(mod)) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"@\" + DBAnnotatedColumn.class.getSimpleName() +\n\t\t\t\t\t\t\t\" fields must be static. Got \" + f);\n\t\t\t\t}\n\t\t\t\tif (f.getType() != DBObjectColumn.class) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"@\" + DBAnnotatedColumn.class.getSimpleName() + \" fields must be \" +\n\t\t\t\t\t\t\tDBObjectColumn.class.getSimpleName() + \" type. Got \" + f);\n\t\t\t\t}\n\n\t\t\t\tString name = annotation.value();\n\n\t\t\t\tInteger columnNumber = numbersByName.get(name);\n\t\t\t\tif (columnNumber == null) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"Cannot find column '\" + name + \"' for @\" +\n\t\t\t\t\t\tDBAnnotatedColumn.class.getSimpleName() + \" on \" + f);\n\t\t\t\t}\n\n\t\t\t\tf.setAccessible(true);\n\t\t\t\ttry {\n\t\t\t\t\tDBObjectColumn already = (DBObjectColumn) f.get(null);\n\t\t\t\t\tif (already == null) {\n\t\t\t\t\t\tf.set(null, DBObjectColumn.get(columnNumber.intValue()));\n\t\t\t\t\t}\n\t\t\t\t\telse if (already.columnNumber != columnNumber.intValue()) {\n\t\t\t\t\t\tthrow new AssertionError();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (IllegalAccessException e) {\n\t\t\t\t\tthrow new AssertionError(e);\n\t\t\t\t}\n\t\t\t}\n\t\t}","sourceCodeStart":1168,"sourceCodeEnd":1204,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBCachedObjectStoreFactory.java#L1168-L1204","documentation":"@DBAnnotatedColumn(value=\"x\") must name a column that is also declared by a matching @DBAnnotatedField(column=\"x\"). writeColumnNumbers builds a name->number map from the collected fields, then looks up the handle's declared name; a miss means the handle points at a column that was never registered in the schema, so IllegalArgumentException is thrown.","triggerScenarios":"`numbersByName.get(annotation.value()) == None`. Happens when the @DBAnnotatedColumn value has no matching @DBAnnotatedField with the same column name - a typo, case mismatch, renamed column, or a handle for a column removed in the current schema version.","commonSituations":"Renaming a @DBAnnotatedField's column without updating the @DBAnnotatedColumn handle; renaming a constant; declaring a handle for a column that only exists in another schema version; case differences in the column name string.","solutions":["Ensure a @DBAnnotatedField(column=\"x\") exists whose column() exactly matches the @DBAnnotatedColumn(\"x\") value (case-sensitive).","Grep the type for the column name to spot the typo/mismatch.","If migrating schema, verify @DBAnnotatedObjectInfo version and that the column layout still declares that name."],"exampleFix":"// before\n@DBAnnotatedColumn(\"fullname\")\nstatic DBObjectColumn NAME;\n@DBAnnotatedField(column=\"name\")\nString name;\n// after\n@DBAnnotatedColumn(\"name\")\nstatic DBObjectColumn NAME;\n@DBAnnotatedField(column=\"name\")\nString name;","handlingStrategy":"validation","validationCode":"// Collect column names from @DBAnnotatedField, then verify each @DBAnnotatedColumn name matches.\nSet<String> valueCols = new HashSet<>();\nfor (Field f : objectType.getDeclaredFields()) {\n    DBAnnotatedField a = f.getAnnotation(DBAnnotatedField.class);\n    if (a != None) valueCols.add(a.column());\n}\nfor (Field f : objectType.getDeclaredFields()) {\n    DBAnnotatedColumn c = f.getAnnotation(DBAnnotatedColumn.class);\n    if (c != None && !valueCols.contains(c.value())) {\n        throw new IllegalStateException(\"@DBAnnotatedColumn references unknown column: \" + c.value());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive the @DBAnnotatedColumn value and the matching @DBAnnotatedField column() from a single shared constant to avoid drift.","Add a schema-integrity test that pairs every handle name to a declared field column."],"tags":["database","annotation","schema","configuration"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}