{"record":{"id":"4c5bc0b0a724515b","repo":"hibernate/hibernate-orm","slug":"empty-primarykeyjoincolumns-annotation","errorCode":null,"errorMessage":"Empty '@PrimaryKeyJoinColumns' annotation","messagePattern":"Empty '@PrimaryKeyJoinColumns' annotation","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java","lineNumber":1301,"sourceCode":"\t\t\t\tcase JOINED -> new JoinedSubclass( superEntity, metadataBuildingContext );\n\t\t\t\tcase TABLE_PER_CLASS -> new UnionSubclass( superEntity, metadataBuildingContext );\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate static AnnotatedJoinColumns subclassJoinColumns(\n\t\t\tClassDetails clazzToProcess,\n\t\t\tPersistentClass superEntity,\n\t\t\tMetadataBuildingContext context) {\n\t\t//@Inheritance(JOINED) subclass need to link back to the super entity\n\t\tfinal var joinColumns = new AnnotatedJoinColumns();\n\t\tjoinColumns.setBuildingContext( context );\n\t\tfinal var modelsContext = context.getBootstrapContext().getModelsContext();\n\t\tif ( clazzToProcess.hasAnnotationUsage( PrimaryKeyJoinColumn.class, modelsContext ) ) {\n\t\t\tfinal var columns = clazzToProcess.getRepeatedAnnotationUsages( PrimaryKeyJoinColumn.class, modelsContext );\n\t\t\tif ( columns.length == 0 ) {\n\t\t\t\t// PrimaryKeyJoinColumns must not be empty according to Javadoc\n\t\t\t\tthrow new AnnotationException( \"Empty '@PrimaryKeyJoinColumns' annotation\" );\n\t\t\t}\n\t\t\tfor ( var column : columns ) {\n\t\t\t\tbuildInheritanceJoinColumn(\n\t\t\t\t\t\tcolumn,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tsuperEntity.getIdentifier(),\n\t\t\t\t\t\tjoinColumns,\n\t\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tbuildInheritanceJoinColumn(\n\t\t\t\t\tnull,\n\t\t\t\t\tnull,\n\t\t\t\t\tsuperEntity.getIdentifier(),\n\t\t\t\t\tjoinColumns,\n\t\t\t\t\tcontext","sourceCodeStart":1283,"sourceCodeEnd":1319,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java#L1283-L1319","documentation":"Error \"Empty '@PrimaryKeyJoinColumns' annotation\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A primary-key join column declaration is empty, misplaced, or does not reference the primary key.","commonSituations":"Empty @PrimaryKeyJoinColumns, @PrimaryKeyJoinColumn on a class that forbids it, or a secondary-table join not referencing the primary key.","solutions":["Add at least one @PrimaryKeyJoinColumn inside @PrimaryKeyJoinColumns, or remove the empty annotation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}