Re: Yes, even one more concurrency question - relationship "freshness"
Re: Yes, even one more concurrency question - relationship "freshness"
- Subject: Re: Yes, even one more concurrency question - relationship "freshness"
- From: Chuck Hill <email@hidden>
- Date: Mon, 13 Aug 2007 15:22:07 -0700
On Aug 13, 2007, at 2:56 PM, Miguel Arroz wrote:
Hi!
On 2007/08/13, at 21:44, Chuck Hill wrote:
Then something in your app is refreshing the to-many relationship.
Well, the problem is much more strange than I thought (we are
entering the "you surely know how to have fun with WO" zone!).
Yes, yes we are. :-)
I have the a.bs() to-many relationship.
I have a cycle where I do the following (pseudo-java-code):
while( optimistic locking failures exists ) {
NSMutableArray array = new NSMutableArray();
B newB = makeNewB();
array.addObject(newB);
a.addObjectToBothSidesOfRelationship( b, "bs" );
a.editingContext().processRecentChanges(); // Just in case, but
doesn't appear to help
PrintALotOFStuffHere;
try {
saveChanges();
} catch OL exception {
for all objects obj in array {
obj.removeObjectFromBothSidesOfRelationship( a, "a" );
Have you tried
a.removeObjectFromBothSidesOfRelationship( obj, "bs" );
obj.editingContext().deleteObject(obj);
Have you made other changes in the EC? If not, ec.revert() should
handle all this much more cleanly.
}
array.removeAllObjects();
// Do some refaults
}
}
In "print a lot of stuff", I do print, between other stuff:
- The Bs in the a.bs() relationship.
- The EC deleted, inserted and updated objects.
Well, when there's no OL failure, this works.
When there's a OL failure, on the second try, I get the following:
The "newB" object created on the first cicle run is NOT on the bs
() relationship, neither in inserted, deleted or updated objects of
the EC. It makes sense: I created and destroyed it before being
able to put it on the data storage.
But... it's precisely that object that causes my error. When I
try to saveChanges in the second run, I get an exception saying the
object is not registered on any EC. Also, all it's relationships
are "null", so I did not forget to remove it from any relationship.
Does something else have a relation to the B entity?
So... if my object belongs to no EC, and if it's not related to
any other object... why the heck is it causing problems? It
shoudn't even exist at that point. How can I ask WO why is it
caring about that object when saving?
The only other thing that comes to mind is the ec.undoManager().
Perhaps this is getting called at somepoint and undoing your deletion
of the new B objects. ec.revert()...
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden