Re: Strange error message

Chuck Hill <[email protected]>
Newsgroups gmane.comp.web.webobjects.eof
Organization Global Village Consulting, Inc.
Message-ID <[email protected]>
Perhaps I've misstated it a bit.  It has been a couple of years since I was 
playing with this, but what I recall is....

Somehow EOF associates an EOGlobalID with the entity/class of the EO object.  I 
believe this happens at the time of the fetch.  For single table inheritance it 
would look at the table and the restricting qualifier.  However, once this 
association has been made it does not seem to get changed (you might be able to 
forget the snapshot or something).  If you look at the global ID you will see 
the name of the *root entity* and the PK.  Nothing else.  What I should have 
said is more along the lines of "EOs in an inheritance hierarchy MUST have 
unique primary keys as that is what EOF uses to associate global IDs with which 
entity/class an object is."

As best I recall...

Chuck



Jonathan Rochkind wrote:

> Hmm.  I think you have correctly diagnosed the problem, but the whole 
> thing is kind of confusing to me.
> 
> In my own case, I am using single-table inheritance, with an abstract 
> root entity and entity-based restricting qualifiers for each 
> sub-entity.  I followed directions in Apple's docs to do this.
> 
> Since it's single-table, EOs in the inheritance hiearchy indeed have 
> unique pks.  But you can't tell the entity from the pk. If you just know 
> "pk = 101", that doens't let you know what entity it's from---EOF can't 
> possibly use the pk to differentiate what sub-entity/class a row belongs 
> to.  But you can know what entity it's from by the restricting qualifier
> 
> Things _seem_ to be working okay. I can do a fetch on the abstract root 
> entity, and all my EOs come back of the appropriate concrete sub-class.  
> Everything I'm doing is okay, right?
> 
> EOEntity inheritance makes me very nervous in general; I'm hesitantly 
> trying it out in a rather simple case to see how/if it works.  But the 
> whole thing seems rather fragile.
> 
> At 10:59 AM 10/8/2002 -0700, Chuck Hill wrote:
> 
>> Ah Ha!  I know the answer.  EOs in an inheritance hierarchy MUST MUST 
>> MUST have unique primary keys.  That is the only way that EOF can 
>> differentiate which class an object is.  In your case
>>
>> RootClass ----> EntityA
>>           ----> EntityB
>>
>> No object of EntityA, EntityB (or RootClass if not abstract) can have 
>> the same PK.   If EOF fetches an instance of EntityA with a PK of 
>> 1000, and then fetches an instance of EntityB with a PK of 1000 it 
>> will think (because the EOGlobalID is the same) that the EntityB 
>> instance is actually the EntityA instance.
>>
>>
>> Chuck
>>
>>
>> Camille Troillard wrote:
>>
>>> Hi Chuck,
>>>
>>> On Tuesday, Oct 8, 2002, at 19:34 Europe/Paris, Chuck Hill wrote:
>>>
>>>> I've only seen this happen when inheritance was involved which, I 
>>>> believe, you said was not.  Very strange.
>>>
>>>
>>> Yes, it seems like it.
>>> I didn't explained my problem correctly:
>>> I actually said that the entities cannot be casted from one to other.
>>> But they have the same root class.
>>> I have posted a message to Jonathan on eof mailing list, that details 
>>> the steps to reproduce to have the problem.
>>> You must have received a copy vie the mailing list manager.
>>>
>>> Best Regards,
>>> Camille
>>>
>>>
>>>> Camille Troillard wrote:
>>>>
>>>>> Hi Anjo,
>>>>> First of all, thank you for the help.
>>>>> On Tuesday, Oct 8, 2002, at 18:51 Europe/Paris, Anjo Krank wrote:
>>>>>
>>>>>> This seems like another case of the problem you had with your PKs 
>>>>>> for the reference entities - for which I also have no explanation?
>>>>>
>>>>>
>>>>> I have more infos about my problem:
>>>>> Here are the steps I did to reproduce something "weird".
>>>>> 1. Create an "ODAgency" object.
>>>>> The object has been correctly created in the database (ID: 1000004).
>>>>> 2. Fetch the "ODAgency" objects.
>>>>> Only 2 objects, there should be 3.
>>>>>     A.  I don't see the object I just inserted (though it is in the 
>>>>> DB).
>>>>>     B.  The first one in an ODAgency, the second one is ...  a 
>>>>> ODAdvertiser !!!!
>>>>>         With ID, guess what ??? ID: 1000004 (same as the newly 
>>>>> created advertiser).
>>>>> The thing is that is seems that EOF gets confused with PK.
>>>>> If two entities raws have the same PK, then I have a problem.
>>>>> But I can't tell why ...
>>>>>
>>>>>> Can you post that model somewhere?
>>>>>
>>>>>
>>>>> For reason you understand, I'll post you the model privately.
>>>>> If someone is willing to help me no problem, as far as I know to 
>>>>> who I post the model, then it's ok.
>>>>> Thanks again,
>>>>> Camille
>>>>> _______________________________________________
>>>>> EOF mailing list
>>>>> [email protected]
>>>>> http://www.omnigroup.com/mailman/listinfo/eof
>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>>
>>>> Chuck Hill                                 [email protected]
>>>> Global Village Consulting Inc.             
>>>> http://www.global-village.net
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> EOF mailing list
>>>> [email protected]
>>>> http://www.omnigroup.com/mailman/listinfo/eof
>>>
>>
>>
>> -- 
>>
>> Chuck Hill                                 [email protected]
>> Global Village Consulting Inc.             http://www.global-village.net
>>
>>
>>
>> _______________________________________________
>> EOF mailing list
>> [email protected]
>> http://www.omnigroup.com/mailman/listinfo/eof
> 
> 


-- 

Chuck Hill                                 [email protected]
Global Village Consulting Inc.             http://www.global-village.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.