@SecondaryTable
From CauchoWiki
The @SecondaryTable annotation specifies the name of a secondary database table for an entity, when the entity is split across multiple tables.
@Entity
@Table(name="test")
@SecondaryTable(name="ext")
public class TestBean {
...
}
[edit] Annotation Definition
public @interface SecondaryTable {
String name() default "";
String catalog() default "";
String schema() default "";
PrimaryKeyJoinColumn []pkJoinColumns() default{};
UniqueConstraint[] uniqueConstraints() default {};
}
| attribute | description | default |
|---|---|---|
| name | the database table name | the @Entity name |
| catalog | the database catalog | |
| schema | the database schema | |
| pkJoinColumns | the key columns used to join with the primary @Table | |
| uniqueConstraints | constraint directives when creating the database |
[edit] Related annotations
- @Entity the owning entity
- @Table specifies the primary table
- @Column specifies database column name and types
- @PrimaryKeyJoinColumn specifies column names for foreign keys
[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 (
ID integer primary key,
DATA varchar(255)
)
