Andrus Adamchik wrote:
> Hi Martin,
> this feature is not there yet. In fact one of our contributors, Holger,
> is currently working on it.
Well, I'm obviously not Holger but we've discussed the issue we sat
together last time. Since Holger remains silent I thought I'd just let
you know of the current thoughts we had.
Having sorted relationships that will stay sorted even after you add
some objects to it is not a trivial task. The problem lies in the Java APIs:
The return type for relationships in cayenne is List. However, the
documentation for List states: "The user of this interface has precise
control over where in the list each element is inserted."
Theoretically, if I add an object to a List I'd expect it to be
accessible under the index I used to put the object into the List
(list.add(1, theObject) == list.get(1) == theObject). Now, if the list
will be automatically sorted I cannot be sure of that any more.
Cayenne uses org.objectstyle.cayenne.access.ToManyList for
relationships. Without looking at the source I'd guess that is so
because then you'll be able to map adds to the List to inserts to the
database. Now the problem I mentioned above stays the same: if you
insert an object into the ToManyList at a certain index you'd expect it
to remain there. If the ToManyList was self-sorting, however that
couldn't be guaranteed.
How could this be solved? One solution would be to use the Set interface
rather than the List interface for relationships. I would think however
that List was chosen carefully. Set's objects cannot be accessed by
their index, you'd always have to convert the set toArray() or something
like that. I doubt if that would be practical.
Does anybody have any idea on how to solve this?
-dirk
This archive was generated by hypermail 2.0.0 : Thu Nov 14 2002 - 22:49:09 EST