Hi Kieran,
That is an interesting thought. To mark the relationship as "Mandatory"
but yet leave the foreign key itself as optional ("allows null"). You
would think the two would need to back each other up though, and to a
casual developer passing by and perusing your model he might think you
were sloppy, or at least not be sure if the relationship should truly be
"mandatory" or "optional".
I understand you are brainstorming here. Thank you for that. But what led
you down the path to this solution? Can you shed some light on why an
object in the "deleted" bucket would get moved to the "updated" bucket
during the various processing that happens when you call
ec.saveChanges()... particularly suspect of "processRecentChanges()" ?
What exactly is happening under the covers to make the "allows null"
option work?
Thank you,
-- Aaron
Kieran Kelleher <[EMAIL PROTECTED]> wrote on 04-08-2008 12:41:43 PM:
> If I have understood you correctly, then this is how I prevent this
> error for mandatory relationships:
>
> 1) Make the relationship foreigh key attribute "AllowNull" in the
eomodel
> 2) Make them NOT NULL in the database (therby ensuring a record with
> NULL foreign key can never be saved or updated anyway
> 3) Set the relationship as mandatory in the EOModel
>
> .... consequences is that your problem goes away, but EntityModeler
> will give you wanrings about mandatory relationship but foreign key
> allows null .....
>
> HTH & YMMV, Kieran
>
> On Aug 4, 2008, at 11:21 AM, [EMAIL PROTECTED] wrote:
>
>
> Hello WOrriors,
>
> We're using WO 5.3.x (not 5.4.x)
>
> I've run into a pickle where if I do an ec.deleteObject() and then
> call ec.saveChanges() I find that this fails during a
> "validateFor*Save*". Curious, indeed, because it should only call
> "validateFor*Delete*". When asking the EC to delete the Object, it
> breaks various mandatory relationships. This, in itself, is ok
> because the object is about to go "bye-bye" and is akin to setting a
> variable to null so you don't accidentally try to reference it
> anymore. Problem is, the object is mysteriously being dropped into
> the "updatedObjects" bucket during "processRecentChanges()"... this
> is what kicks off the validateForSave which of course fails because
> mandatory relationships are purposely broken.
>
> Even more of interest is that this strange transfer from "deleted ->
> updated" status only happens in certain repeatable circumstances. It
> happens when you:
>
> 1) On _page A_ in _EC 1_ *edit a value in the desired EO and save*
> 2) then go to a different _page B_ with _EC 2_ but pass the EO as a
> local object of the new EC
> 3) Attempt to delete and save the local EO in _EC 2_ on _page B_.
>
> The above will happen every time. However, if I repeat those above
> steps but "do not edit the EO" in step 1, then everything goes
> according to plan and the object actually deletes.
>
> This is all on my local machine in dev mode with DirectConnect.
> Nothing funny with multiple concurrent access. Strangely, if I step
> into ec.saveChanges() and then ec.processRecentChanges() and step a
> bit there then hit "continue" in the debugger... the marked for
> delete object *stays* in the delete bucket and deletes as desired.
> So odd! It's as if there is a concurrent process going on in
> processRecentChanges that if tripped at the right time, maybe a
> deferred fault (or something) gets fired and causes an object to
> move from the deleted -> updated bucket.
>
> I've searched a bit on the listserv archives and have seen some
> notable people have had similar issues in the past. For example this
> posting between Lenny, Chuck, and Christian:
>
> http://www.mail-archive.com/[email protected]/msg04553.html
>
> I've tried the code fix to EOEditingContext offered here and found
> that it stops the Validation Error but doesn't actually delete the
> desired EO either.
>
> If anyone has any insight on this issue I'm all ears and appreciate
> your thoughts and concern. Anything like:
>
> 1) Is this a confirmed bug by Apple that might be fixed in WO 5.4 or
> at least has an open Radar ticket?
>
> 2) Is there possibly something similar that has bit you that you
> think I also might be doing wrong and overlooking?
>
> 3) Have other peoople used Lenny's fix and had any other thoughts or
tweaks?
>
> Thanks in advance,
> -- Aaron _______________________________________________
> 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/kieran_lists%40mac.com
>
> This email sent to [EMAIL PROTECTED]
_______________________________________________
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]