// FK referencing an entity with a basic PK (single attribute)
@FK( ReferencedEntity ) // without FK name (default name)
@FK( ForeignKeyName, ReferencedEntity ) // with FK name
---
// FK referencing an entity with a compositePK (N attributes)
@FK( ForeignKeyName, ReferencedEntity.ReferencedAttribute )
Examples :
// FK referencing "Brand" entity (with default FK name)
brandId : int { @FK(Brand) }; // PK inference
-----
// FK referencing "Brand" entity (with default FK name)
brandId : int { @FK(Brand.id) }; // explicit PK attribute
-----
// FK referencing "Group" entity (with FK name)
groupCode : string { @FK(FK_EMP_GRP, Group) } ;
-----
// FK referencing "SubGroup" entity (composite PK)
groupCode : string { @FK(FK_PER_SUBGRP, SubGroup.groupCode ) };
subgroupId : int { @FK(FK_PER_SUBGRP, SubGroup.subgroupId) };
@GeneratedValue(AUTO)
@GeneratedValue(IDENTITY)
@GeneratedValue(SEQUENCE [, GeneratorName, SequenceName
[, AllocationSize ] ])
@GeneratedValue(TABLE [, GeneratorName, TableName
[, PkColumnName, PkColumnValue, ValueColumnName [, AllocationSize ] ] ])
Badge { // Simple key => single "@Id"
id : int { @Id } ;
name : string ;
}
SubGroup { // Composite key => multiple "@Id"
groupCode : string { @Id } ;
sectionId : int { @Id } ;
name : string ;
}
shops : Shop[] { @MappedBy(employee) } ;