cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Lamb (dev)" <al...@mac.com>
Subject Re: Duplicates in to-many relationships
Date Tue, 19 Jun 2007 19:14:14 GMT
Thanks a lot. It is again my WO habit where we did the  
"addToBothSidesOfRelationshipWithKey" !

Works fine now!

Alex

Le 19 juin 07 à 18:17, Mike Kienenberger a écrit :

> And note that if you call
> "myFirstObject.addToMyRelation(mySecondObject)", then
> "mySecondObject.setTheObject(myFirstObject)" is also called.   It
> doesn't matter which side of the relationship you call.   Furthermore,
> if mySecondObject.getTheObject() = myZeroObject beforehand, this
> object will also be removed from the relationship list automatically.
> Ie, everything "just works" out of the box with no extra effort on
> your part.
>
> On 6/19/07, Mike Kienenberger <mkienenb@gmail.com> wrote:
>> 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.
>>
>>
>>
>> On 6/19/07, Alexander Lamb (dev) <alamb@mac.com> wrote:
>> > Hello list,
>> >
>> > It looks like "myFirstObject.addToMyRelation(mySecondObject)" does
>> > not check if mySecondObject is already in the relationship. Is that
>> > correct?
>> >
>> > If so, here is my problem.
>> >
>> > I know that I can simply do:
>> >
>> > mySecondObject.setTheObject(myFirstObject)
>> >
>> > and then once saved, somehow the reverse relationship will be  
>> updated.
>> >
>> > The problem is that I need the reverse relationship before I save.
>> > Therefore I do:
>> >
>> > mySecondObject.setTheObject(myFirstObject)
>> >
>> > and
>> >
>> > myFirstObject.addToMyRelation(mySecondObject)
>> >
>> > In order to have my object graph correct before save.
>> >
>> > Unfortunately, doing this it seems like mySecondObject gets  
>> inserted
>> > twice in the List. If I restart the app, everything is fine again.
>> >
>> > Thanks for any hint!
>> >
>> > Alex
>> >
>>


Mime
View raw message