Java Reference
In-Depth Information
The set Collection
A set collection allows collection attributes derived from the Set interface to be persisted.
In addition to the common collection mappings, the <set> element offers the inverse ,
order-by , and sort attributes, as shown in Table 7-11.
Table 7-11. The Additional <set> Attributes
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.
order-by
Specifies an arbitrary SQL order by clause to constrain
the results returned by the SQL query that populates
the set collection.
sort
Specifies the collection class sorting to be used. The
value can be unsorted , natural , or any Comparator
class.
The child elements of the <set> element are as follows:
(meta*,
subselect?,
cache?,
synchronize*,
comment?,
key,
(element | one-to-many | many-to-many |
composite-element | many-to-any),
loader?,
sql-insert?,
sql-update?,
sql-delete?,
sql-delete-all?,
filter*)
The following code shows an implementation of mapping a set of strings into a property
called titles :
<set name="titles" table="nameset">
<key column="titleid"/>
<element type="string" column="name" not-null="true"/>
</set>
A typical implementation, however, maps other entities into the collection. Here we map
Phone entities from the “many” side of a one-to-many association into a Set property, called
phoneNumbers , that belongs to a User entity:
Search WWH ::




Custom Search