Top Description Methods
jakarta.persistence

public @Interface SecondaryTables

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
Imports
java.lang.annotation.Target, .Retention

Specifies multiple secondary tables for an entity.

Example 1: Multiple secondary tables assuming primary key columns are named the same in all tables.

@Entity @Table(name = "EMPLOYEE") @SecondaryTables({ @SecondaryTable(name = "EMP_DETAIL"), @SecondaryTable(name = "EMP_HIST")}) public class Employee { ... }
@Entity
@Table(name = "EMPLOYEE")
@SecondaryTables({
    @SecondaryTable(name = "EMP_DETAIL"),
    @SecondaryTable(name = "EMP_HIST")})
public class Employee { ... }

Example 2: Multiple secondary tables with differently named primary key columns.

@Entity @Table(name = "EMPLOYEE") @SecondaryTables({ @SecondaryTable(name = "EMP_DETAIL", pkJoinColumns = @PrimaryKeyJoinColumn(name = "EMPL_ID")), @SecondaryTable(name = "EMP_HIST", pkJoinColumns = @PrimaryKeyJoinColumn(name = "EMPLOYEE_ID"))}) public class Employee { ... }
@Entity
@Table(name = "EMPLOYEE")
@SecondaryTables({
    @SecondaryTable(name = "EMP_DETAIL",
                    pkJoinColumns = @PrimaryKeyJoinColumn(name = "EMPL_ID")),
    @SecondaryTable(name = "EMP_HIST",
                    pkJoinColumns = @PrimaryKeyJoinColumn(name = "EMPLOYEE_ID"))})
public class Employee { ... }
Since
1.0

Method Summary

Modifier and TypeMethod and Description
public SecondaryTable[]
value()

(Required) The secondary tables for an entity.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public SecondaryTable[] value()

(Required) The secondary tables for an entity.