Java Reference
In-Depth Information
Table 4-2. ( continued )
Annotation
Description
Elements
@MapKeyJoinColumn
Specify foreign key mappings to entities that are map keys in
map-valued element collections or relationships. In general,
the foreign key definitions created should be expected to be
provider-dependent and database-dependent. Applications
that are sensitive to the exact mapping that is used should
use the foreignKey element of the MapKeyJoinColumn
annotation or include DDL files that specify how the
database schemas are to be generated.
name
referencedColumnName
unique
nullable
columnDefinition
table
foreignKey
@PrimaryJoinKeyColumn Specifies that a primary key column is to be used as a foreign
key. This annotation is used in the specification of the
JOINED mapping strategy and for joining a secondary table
to a primary table in a OneToOne relationship mapping.
In general, the foreign key definitions created should be
expected to be provider-dependent and database-dependent.
Applications that are sensitive to the exact mapping that
is used should use the foreignKey element of the
PrimaryKeyJoinColumn annotation or include DDL files that
specify how the database schemas are to be generated.
@ForeignKey
Used within the JoinColumn, JoinColumns,
MapKeyJoinColumn, MapKeyJoinColumns,
PrimaryKeyJoinColumn, and PrimaryKeyJoinColumns
annotations to specify or override a foreign keyconstraint.
@SequenceGenerator
Creates a database sequence to be used for Id generation.
The use of generators is limited to those databases that
support them.
@Index
Generates an index consisting of the specified columns. The
ordering of the names in the columnList element specified in
the Index annotation must be observed by the provider
when creating the index.
@UniqueConstraint
Generates a unique constraint for the given table. Databases
typically implement unique constraints by creating unique
indexes. The ordering of the columnNames specified in
the UniqueConstraint annotation must be observed by the
provider when creating the constraint.
As per Table 4-2 , there are a couple of new annotations that have been created specifically to facilitate schema
generation. The new annotations are @Index and @ForeignKey , where @Index is responsible for generating an index of
the specified columns. @ForeignKey is used to define a foreign key on a table.
Search WWH ::




Custom Search