Java Reference
In-Depth Information
<property name="javax.persistence.schema-generation.scripts.create-target"
value="/ddl-scripts/create-trarget-script.ddl"/>
<property name="eclipselink.deploy-on-startup" value="true"/>
</properties>
</properties>
</persistence-unit>
</persistence>
Programmatically, schema generation is determined by a series of annotations that are placed in entity classes.
The @Table annotation denotes an entity mapping to an underlying database table. By default, a table is generated for
each top-level entity and includes columns based upon the specified attributes for that entity. Therefore, the @Column
and @JoinColumn annotations are used for generating such columns for a table. Column ordering is not determined
based upon the ordering of @Column or @ JoinColumn annotations. If column ordering is important then a Data
Definition Language (DDL) script must be supplied for generation of the table. Other annotations and annotation
attributes, such as @Id , also play important roles in schema generation. Table 4-2 lists the different annotations that
are involved in schema generation, along with a brief description and the elements that can be populated for further
control over the generated schema.
Table 4-2. Schema Generation Annotations
Annotation
Description
Elements
@Table
Used for generating tables. By default, the table name is
generated from the entity name, and the entity name is
defaulted from the class name.
@SecondaryTable
A secondary table is created to partition the mapping of
entity state across multiple tables.
@CollectionTable
A colletion table is created for mapping of an element
collection. The Column, AttributeOverride, and
AssociationOverride annotations may be used to override
CollectionTable mappings.
@JoinTable
By default, join tables are created for the mapping of
many-to-many relationships and unidirectional one-to-
many relationships.
@TableGenerator
Table generator tables are used to store generated primary
key values.
@Column
Determines the name and configuration for a column within
a table.
unique
nullable
columnDefinition
table
length
precision
scale
name
( continued )
 
Search WWH ::




Custom Search