I was wondering if EOF simply did not support this for primary keys but did not 
dig that far.  I have looked a little more and I think your conclusion is 
correct.  You could like find a way to get it use custom EOEntity/EOAttribute 
classes, but that might be more effort than it is worth to you.

Chuck 




On 2016-01-26, 12:24 PM, "Samuel Pelletier" <sam...@samkar.com> wrote:

>Hi Chuck,
>
>After digging and stepping into the debugger, I figured out that the problem 
>come in the globalID generation that uses the adaptorValueClass() method of 
>EOAttribute which in turn uses the adaptorValueType() with only support 4 
>types (String, Number, Data and NSTimestamp).
>
>This part is totally broken with custom data type.
>
>My conclusion is custom data type are not supported as PK attributes.
>
>I create a work around in my DateMTA entity (used for report grouping by 
>month, quarter, year, ...)
>
>       static public DateMTA forDate(EOEditingContext ec, LocalDate date) {
>               synchronized (GLOBAL_ID) {
>                       if (_gids == null) {
>                               NSMutableDictionary<LocalDate, EOGlobalID> gids 
> = new NSMutableDictionary<LocalDate, EOGlobalID>();
>                               for (DateMTA dateMTA : fetchAllDateMTAs(ec)) {
>                                       
> gids.setObjectForKey(dateMTA.globalId(), dateMTA.date());
>                               }
>                               _gids = gids.immutableClone();                  
>                                 
>                       }
>                       EOGlobalID globalID = _gids.objectForKey(date);         
>         
>                       return (DateMTA) ec.faultForGlobalID(globalID, ec);
>               }
>       }
>
>and when I need the relationship, I add this to the entity class:
>
>       public static ERXKey<DateMTA> DATE_MTA = new ERXKey<DateMTA>("dateMta");
>       private DateMTA dateMta;
>
>       public DateMTA dateMta() {
>               if (dateMta == null) {
>                       dateMta = DateMTA.forDate(editingContext(), date());
>               }
>               return dateMta;
>       }
>
>
>It would be much nicer to simply create the relationship but for in memory 
>stuff, this works great and stiff very efficient.
>
>Regards,
>
>Samuel
>
>
>> Le 26 janv. 2016 à 14:20, Chuck Hill <ch...@gevityinc.com> a écrit :
>> 
>> How did you define the PK?  You will need to set it up as a custom data 
>> type, the same as if you were using it as a regular attribute.  Why does it 
>> think it is a NSTimestamp?
>> 
>> Chuck
>> 
>> 
>> 
>> 
>> 
>> On 2016-01-22, 2:35 PM, 
>> "webobjects-dev-bounces+chill=gevityinc....@lists.apple.com on behalf of 
>> Samuel Pelletier" 
>> <webobjects-dev-bounces+chill=gevityinc....@lists.apple.com on behalf of 
>> sam...@samkar.com> wrote:
>> 
>>> Hi,
>>> 
>>> I would like to create use a soda LocalDate as primary key for an entity 
>>> used for report grouping with month, quarter, year...
>>> 
>>> My creates and inserts works but my fetches fail with this exception:
>>> Attempt to create an EOGlobalID for the entity "DateMTA" with a primary key 
>>> component of type org.joda.time.LocalDate instead of type 
>>> com.webobjects.foundation.NSTimestamp!
>>> at com.webobjects.eoaccess.EOEntity._coercePKInput(EOEntity.java:390)
>>> 
>>> I dig a bit in the code and it seems to come from the adaptorValueClass() 
>>> method in EOAttribute that think it should be a NSTimestamp instead of an 
>>> LocalDate.
>>> 
>>> I am not familial with EOAtribute and it's multiple class and types...
>>> 
>>> Anyone can help me figure this out ?
>>> 
>>> Samuel
>>> _______________________________________________
>>> 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:
>>> https://lists.apple.com/mailman/options/webobjects-dev/chill%40gevityinc.com
>>> 
>>> This email sent to ch...@gevityinc.com
>

 _______________________________________________
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:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to