Well, although it works, I still have a small problem.
When you do a "setAnObject" even if it does "magically" handle the
"addTo", it does so without calling the public "addToMyList" function.
This means I can't add some logic to the addTo function (I need to
perform some calculation each time a new object is added to the list.
So either I find some sort of "objectWasAddedToRelationship" delegate
message, or I will need to trigger the calculation also from the
"setAnObject" side.
To answer directly your question, I do need sometimes a sorted list
but I usually don't touch the to-many relation. I simply create a new
function which sorts the to-many list. In order to boost performance,
I do keep an ArrayList variable which is calculated once and only
reset when the to-many list changes. Another reason to need to be
able to access the addToMyList when I can reset my calculated sorted
list.
Alex
Le 19 juin 07 à 23:12, Kevin Menard a écrit :
While this is true, I always thought a ToManyList really should be an
ordered set. I must admit, I was a bit perplexed the first time I
ended
up with duplicates in one of my lists, but found the DB inserts were
correct. I actually had one Web app where it wasn't clear how
duplicates were getting in at all, so I wrote an
EnhancedCayenneDataObject that specifically disallowed duplicates
being
added. A bit of a performance hit, for sure, but the underlying data
model matched the DB much more accurately and I only paid the price
when
calling on of the add-to-list methods.
--
Kevin
-----Original Message-----
From: Mike Kienenberger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 19, 2007 12:15 PM
To: [email protected]
Subject: Re: Duplicates in to-many relationships
Unlike Hibernate, the object graph is maintained even before you
save.
If you use "mySecondObject.setTheObject(myFirstObject)", then
the equivalent for
"myFirstObject.addToMyRelation(mySecondObject)" is already
done for you.
This is why you're seeing two copies -- you're effectively
calling the addToMyRelationship twice.