jakarta.persistence.SecondaryTable
- Implemented Interfaces:
Annotation
- Target:
- Type
If no SecondaryTable annotation is specified, it is assumed that all persistent fields or properties of the entity are mapped to the primary table. If no primary key join columns are specified, the join columns are assumed to reference the primary key columns of the primary table, and have the same names and types as the referenced primary key columns of the primary table.
Example 1: Single secondary table with a single primary key column.
@Entity @Table(name = "CUSTOMER") @SecondaryTable(name = "CUST_DETAIL", pkJoinColumns = @PrimaryKeyJoinColumn(name = "CUST_ID")) public class Customer { ... }
Example 2: Single secondary table with multiple primary key columns.
@Entity @Table(name = "CUSTOMER") @SecondaryTable(name = "CUST_DETAIL", pkJoinColumns = { @PrimaryKeyJoinColumn(name = "CUST_ID"), @PrimaryKeyJoinColumn(name = "CUST_TYPE")}) public class Customer { ... }
This annotation may not be applied to a class annotated MappedSuperclass or Embeddable.
- Since:
- Jakarta Persistence (JPA) 1.0
Annotation Elements
String name- Since:
- Jakarta Persistence (JPA) 1.0
String catalogDefaults to the default catalog.
- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 1.0
String schemaDefaults to the default schema for user.
- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 1.0
Defaults to the column(s) of the same name(s) as the primary key column(s) in the primary table.
- Default:
- {}
- Since:
- Jakarta Persistence (JPA) 1.0
#foreignKey element of any of the pkJoinColumns elements are specified, the behavior is undefined. If no foreign key annotation element is specified in either location, a default foreign key strategy is selected by the persistence provider.- Default:
- @ForeignKey(ConstraintMode.PROVIDER_DEFAULT)
- Since:
- Jakarta Persistence (JPA) 2.1
Column and JoinColumn annotations and constraints entailed by primary key mappings. Defaults to no additional constraints.
- Default:
- {}
- Since:
- Jakarta Persistence (JPA) 1.0
- Default:
- {}
- Since:
- Jakarta Persistence (JPA) 2.1
- Default:
- {}
- Since:
- Jakarta Persistence (JPA) 3.2
String comment- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 3.2
String options- Default:
- ""
- Since:
- Jakarta Persistence (JPA) 3.2
Additional JDK methods inherited from java.lang.annotation.Annotation
annotationType(), equals(Object), hashCode(), toString()