On Aug 28, 2006, at 8:48 PM, Chuck Hill wrote:
On Aug 28, 2006, at 10:41 AM, Fabrice Pipart wrote:
Hi list !
I recently solved a bug I had but I still wonder why it happened.
Could someone help me understand the following?
Lets say I have a relationship between A and B : A <<--> B
In EOModeler both have diamonds (accessible via code)
I have two threads
In thread1 (locked of course)
I fetch B1
In thread2 (locked of course)
I modify B1 : B1.value changed from 1 to 2
I saveChanges() : B1.value is 2
In thread1
I create A1 and call A1.addObjectToBothSidesOfRelationshipWithKey(B1, "B");
I saveChanges
At that moment I have my B that has a value back to 1.
In thread 1? In the database? I would expect it to be 1 in Thread one as it is still locked and that prevents external changes from affecting it. It should not be 1 in the database.
It's one in both actually.
And that's what is scary.
I don't have any InvalideStateException when I do saveChanges in thread1
B1 is actually changed in thread2
Though only B1's relationship are changed in thread1
I found why. Just because I set the A.B relationship in thread1, B is part of the thread1 ec's "unprocessedChanges"
The relationship should be, but not B's values as you have not changed them.
What do you mean by "the relationship" ?
B in database don't know anything about A, only A has a B foreign id
And therefore, its the old value of B that is saved in thread1
If I remove the diamond in Bs relationship it works fine
Is this a normal behavior?
Do I do something wrong?
Sounds odd if it is getting into the database.
Just what I thought...
Would you like to see the code or other details to help me understand where the problem is ?
Fabrice
Chuck
--