Thanks so much for your quick response Chuck. We use Frontbase. I have no FK issue here. It's just that the objects should be inserted to DB in the order I have created and inserted into EC.
Why EC saveChanges() operation just not save the objects in the order of insertion??? Isn't it simple? I believe EC maintains an array insertedObjects(), so it should just follow that array order, unless otherwise any constraints as you have mentioned!!! Just trying to understand the mystery behind the complexity :) If there's no built-in solution, then probably adding a "sortOrder" field to my table would fix this issue. Thank You, Shravan Kumar. M ________________________________ From: Chuck Hill <[email protected]> To: Shravan Kumar. M <[email protected]> Cc: WO Dev Group <[email protected]> Sent: Sun, November 1, 2009 8:49:54 AM Subject: Re: how to insert records in database in the order of insertion to EC On Oct 31, 2009, at 6:57 PM, Shravan Kumar. M wrote: > Hi Group, > > Could any one please advise me how can I insert records in database in a > specific order or as per the order of insertion of objects to EditingContext AFAIK, you can't. The order of insertion is not tracked. > for eg: > > I have inserted objects to EC in the following order: A1, A2, A3, A4, A5 (and > then saved the EC once - editingContext.saveChanges()) > But, when these got saved to database the order is disturbed and is not > guaranteed i.e., I see following order sometimes: A2, A5, A1, A3, A4, whereas > I want the order of these objects as I have inserted to EC. > > I heard that we can do something with AdaptorOperations, but not sure of that > exactly and am trying to see if we have an higher level API for that. (Just a > note: We do not use Wonder to the fullest, of course we use Wonder API's as > required.) If your problem is FK constraint violations, make the constraints DEFERRABLE INITIALLY DEFERRED when you create them. If you are using MS SQL Server, then you are in a world of hurt. It includes not supporting deferrable constraints in its set of unsupported yet highly desirable features. There is a reason why people mock that "database". You can order the operations using EOF but (a) is isn't easy and (b) you can't expect to know the order of insertion and (c) I can't think of many useful examples to follow. You could start with the source for my http://www.global-village.net/chill/ms_sql_server_eof_plugin Chuck --Chuck Hill Senior Consultant / VP Development 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 protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
