@PrimaryKeyJoinColumn
From CauchoWiki
The @PrimaryKeyJoinColumn is used with a @SecondaryTable to specify the primary key/foreign keys to join the @SecondaryTable to the @Table for an entity which is split across multiple tables.
@Entity
@Table(name="test")
@SecondaryTable(name="ext",
pkJoinColumns={
@PrimaryKeyJoinColumn(name="ext_id",
referencedColumnName="ID")})
public class TestBean {
...
}
[edit] Annotation Definition
public @interface PrimaryKeyJoinColumn {
String name() default "";
String referencedColumnName() default "";
String columnDefinition() default "";
}
| attribute | description | default |
|---|---|---|
| name | the column name of the secondary table key | the @Id name |
| referencedColumnName | the primary key name for the id | |
| columnDefinition | the actual column definition |
[edit] Related annotations
- @SecondaryTable specifies the primary table
[edit] Example
@Entity
@Table(name="test")
@SecondaryTable(name="ext")
public class TestBean {
@Id
private int id;
@Basic
@Column(table="ext")
private String data;
}
create table test (
ID integer primary key
)
create table ext (
ext_id integer primary key,
DATA varchar(255)
)
