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

-- 

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.    http://www.global-village.net/products/practical_webobjects






www.easyshadow.com

International Corporate Consulting
Palais de la Scala
1 avenue Henri Dunant
Suite 1155
MC - 98000 Monaco

Skype: fabrice.pipart
Tel.  +377 97 98 21 04 (direct)
Fax. +377 97 70 88 07



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to