Java Reference
In-Depth Information
A typical implementation of a list mapping is as follows:
<list name="list" table="namelist">
<key column="fooid"/>
<index column="position"/>
<element type="string" column="name" not-null="true"/>
</list>
The idbag Collection
An idbag collection allows for appropriate use of collection attributes derived from the List
interface. A bag data structure permits unordered storage of unordered items, and permits
duplicates. Because the collection classes do not provide a native bag implementation, classes
derived from the List interface tend to be used as a substitute. The imposition of ordering
imposed by a list is not itself a problem, but the implementation code can become depend-
ent upon the ordering information.
idbag usually maps to a List . However, by managing its database representation with
a surrogate key, you can make the performance of updates and deletions of items in a col-
lection defined with idbag dramatically better than with an unkeyed bag (described at the
end of this section). Hibernate does not provide a mechanism for obtaining the identifier
of a row in the bag .
In addition to the common collection mappings, the <idbag> element offers the order-by
element, as shown in Table 7-13.
Table 7-13. The Additional <idbag> Attribute
Attribute
Values
Default
Description
order-by
Specifies an arbitrary SQL order by clause to constrain
the results returned by the SQL query that populates the
collection
The child elements of the <idbag> element are as follows:
(meta*,
subselect?,
cache?,
synchronize*,
comment?,
collection-id,
key,
(element | many-to-many |
composite-element | many-to-any),
loader?,
sql-insert?,
sql-update?,
sql-delete?,
sql-delete-all?,
filter*)
Search WWH ::




Custom Search