Hibernate version: 3.0.5
I have read the documentation regarding indexed collections, but I have
not found (in the reference manual at least) an answer to several
questions about managing list collections with Hibernate:
0. Does the list index column need to also be a property of the child
object, or does it only need to be declared as a column in the db?
1. Does Hibernate compute the list index for a list element? I am not
clear on what happens when, for example the object containing a
list is loaded, and presumably the list itself is only lazily loaded, and
then an item is added to the list or inserted in the middle - who's
responsible for making sure the list stays consistent?
2. When/where does this happen if Hibernate does compute the list
index? Does this happen when flushing new objects?
3. One solution I've seen for managing the list index is presented in
http://www.hibernate.org/193.html However, there are several
questions I have regarding this:
a. A performance/efficiency issue: what happens when the list gets large
(100's or 1000's of items) and the 'getIndex()' is being called?
In particular is the list is initialised lazily and list items are
retrieved as they are being accessed. Is this a price that needs to
be paid or is this not an issue?
b. What if the index column is something that consitutes part of the
natural key (something like order line number) - when retrieving
the element index value, the solution uses the 'indexOf' method on
the parent object's list, which uses the 'equals' method, causing
infinite recursion. How does one avoid this?
Thanks in advance for any assistance here.[/list]