Java Reference
In-Depth Information
The child elements of the <component> element are as follows:
(meta*,
tuplizer*,
parent?,
(property | many-to-one | one-to-one |
component | dynamic-component | any |
map | set | list | bag |
array | primitive-array)* )
We provide a full example of the use of the <component> element in the “Mapping Compo-
sition” section later in this chapter.
The <one-to-one> Element
The <one-to-one> element expresses the relationship between two classes, where each instance
of the first class is related to a single instance of the second, and vice versa. Such a one-to-one
relationship can be expressed either by giving each of the respective tables the same primary
key values, or by using a foreign key constraint from one table onto a unique identifier column
of the other. Table 7-8 shows the attributes that apply to the <one-to-one> element.
Table 7-8. The <one-to-one> Attributes
Attribute
Values
Default
Description
access
Specifies how the class member should be accessed:
field for direct field access or attribute for access
via the get and set methods.
cascade
Determines how changes to the parent entity will
affect the linked relation.
check
The SQL to create a multirow check constraint for
schema generation.
class
The property type of the attribute or field (if omit-
ted, this will be determined by reflection).
constrained
true , false
Indicates that a foreign key constraint on the primary
key of this class references the table of the associated
class.
embed-xml
true , false
When using XML relational persistence, indicates
whether the XML tree for the associated entity itself,
or only its identifier, will appear in the generated
XML tree.
entity-name
The entity name of the associated class.
fetch
join , select
The mode in which the element will be retrieved
( outer join , a series of select s, or a series of subse-
lect s). Only one member of the enclosing class can
be retrieved by outer join .
foreign-key
The name to assign to the foreign key enforcing the
relationship.
formula
Allows the value to which the associated class maps
its foreign key to be overridden using an SQL formula.
Continued
Search WWH ::




Custom Search