JPA Annotation

JoinColumns

Target: METHOD, FIELD
Implemented Interfaces:
Annotation

Specifies the mapping for composite foreign keys. This annotation groups JoinColumn annotations for the same relationship.

When the JoinColumns annotation is used, both the name and the referencedColumnName elements must be specified in each such JoinColumn annotation.

Example:
    @ManyToOne
    @JoinColumns({
        @JoinColumn(name="ADDR_ID", referencedColumnName="ID"),
        @JoinColumn(name="ADDR_ZIP", referencedColumnName="ZIP")
    })
    public Address getAddress() { return address; }
See Also:
JoinColumn
ForeignKey
Since:
JPA 1.0

Public Annotation Attributes

ForeignKey foreignKey default @ForeignKey(PROVIDER_DEFAULT)
(Optional) Used to specify or control the generation of a foreign key constraint when table generation is in effect.
If both this element and the foreignKey element of any of the JoinColumn elements are specified, the behavior is undefined. If no foreign key annotation element is specified in either location, the persistence provider's default foreign key strategy will apply.
Since:
JPA 2.1
JoinColumn[] value default null
The join columns that map the relationship.
Since:
JPA 1.0