Java Reference
In-Depth Information
<one-to-one
name="campaign"
class="com.hibernatebook.xmlmapping.Campaign"
property-ref="product"/>
The format used in this example is the most common. The body of the element consists
of an infrequently used optional element:
(meta* | formula*)
We discuss the <many-to-many> element and the alternative approach of composition in
some detail in the “Mapping Collections” section later in this chapter.
The <many-to-one> Element
The many-to-one association describes the relationship in which multiple instances of one
class can reference a single instance of another class. This enforces a relational rule for which
the “many” class has a foreign key into the (usually primary) unique key of the “one” class.
Table 7-9 shows the attributes permissible for the <many-to-one> element.
Table 7-9. The <many-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.
class
The property type of the attribute or field (if omitted,
this will be determined by reflection).
column
The column containing the identifier of the target
entity (i.e., the foreign key from this entity into the
mapped one).
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 name of the associated entity.
fetch
join , select
The mode in which the element will be retrieved
( outer join , a series of select s, or a series of
subselect s). Only one member of the enclosing class
can be retrieved by outer join .
foreign-key
The name of the foreign key constraint to generate
for this association.
formula
An arbitrary SQL expression to use in place of the nor-
mal primary key relationship between the entities.
index
The name of the index to be applied to the foreign
key column in the parent table representing the
“many” side of the association.
Continued
Search WWH ::




Custom Search