Java Reference
In-Depth Information
<set name="phoneNumbers">
<key column="aduser"/>
<one-to-many class="sample.Phone"/>
</set>
If the Phone class contains a reference to a User object, it is not automatically clear whether
this constitutes a pair of unrelated associations or two halves of the same association—a
bidirectional association. When a bidirectional association is to be established, one side must
be selected as the owner (in a one-to-many or many-to-one association, it must always be the
“many” side), and the other will be marked as being the inverse half of the relationship. See the
discussion of unidirectional and bidirectional associations at the end of Chapter 4. The follow-
ing code shows a mapping of a one-to-many relationship as a reverse association.
<set name="phoneNumbers" inverse="true">
<key column="aduser"/>
<one-to-many class="sample.Phone"/>
</set>
The list Collection
A list collection allows collection attributes derived from the List interface to be persisted.
In addition to the common collection mappings, the <list> element offers the inverse
attribute, as shown in Table 7-12.
Table 7-12. The Additional <list> Attribute
Attribute
Values
Default
Description
inverse
true , false
false
Specifies that an entity is the opposite navigable end of
a relationship expressed in another entity's mapping
The child elements of the <list> element are as follows:
(meta*,
subselect?,
cache?,
synchronize*,
comment?,
key,
(index | list-index),
(element | one-to-many | many-to-many |
composite-element | many-to-any),
loader?,
sql-insert?,
sql-update?,
sql-delete?,
sql-delete-all?,
filter*)
Search WWH ::




Custom Search