Thanks Andrus, however, I am not doing relationship management in that case.
Actually, I do NOT want to remove the center from the selected country.
What I am doing is taking the centers and removing some items to present to the user the centers which are not already present in another relationship.
In other words: "remove from the centers of the country the ones which are already used for a registry". Then present the list to the user so he can select a center he may want to add for a registry (or let him create a new center).
So it is more like if I made a temporary copy of a list of objects to work with.
And, yes, for consistency it would seem better to first fire a list fault before. But there was maybe some historical reason not to do it (I looked in the code and there is some testing of the status of the list and object that I didn't really understand).
On Thursday, May 24, 2007, at 11:20AM, "Andrus Adamchik" <andru..bjectstyle.org> wrote:
>I suggest using "getSelectedCountry().removeFromCenters(..)" for
>consistent behavior. As for the remove, maybe we should fire a list
>fault for consistency, but this hasn't been a big deal as
>relationship management is better done via special methods.
>
>Andrus
>
>
>On May 24, 2007, at 10:54 AM, Alexander Lamb wrote:
>> Hello list,
>>
>> I am fetching a "List" of objects (a too many relationship).
>>
>> Then in a loop, I am removing some objects:
>>
>> List<RegistryCenter> rcs = getRegistry().getRegistryCenters();
>> List centers = getSelectedCountry().getCenters();
>> for(RegistryCenter rc:rcs)
>> {
>> centers.remove(rc.getCenter());
>> }
>>
>>
>> Now, this doesn't always work. Actually, it fails if "centers" is a
>> fault (I checked in the Cayenne code).
>>
>> If I simply do a "size()" of "contains" on the list before my loop
>> for example. My list will fire and my loop will function correctly,
>> removing objects when present in the list.
>>
>> So there is a workaround, but I was wondering why the "remove
>> (object)" in ToManyList.java behaved differently than for example
>> "remove(index)" which will correctly fire the fault.
>>
>> In other words, "remove(object)" is the only function which does
>> not systématically fire the fault.
>>
>> Why?
>>
>> Thanks,
>>
>> Alex
>>
>>
>
>
>
This archive was generated by hypermail 2.0.0 : Thu May 24 2007 - 05:37:04 EDT