Awesome, thank you for that code Andrus. 

Ricardo Parada



> 
> On Oct 25, 2025, at 12:16 PM, Andrus Adamchik <[email protected]> wrote:
> 
> Hi Ricardo,
> 
> A rough equivalent used by Cayenne internally is this:
> 
>  ObjectId oid = ObjectId.of(entityName, "PK_COL_NAME", id);
>  ClassDescriptor descriptor = 
> context.getEntityResolver().getClassDescriptor(entityName);
> 
>  Persistent o = (Persistent) descriptor.createObject();
>  o.setObjectContext(context);
>  o.setObjectId(oid);
>  o.setPersistenceState(PersistenceState.HOLLOW);
> 
>  context.getGraphManager().registerNode(oid, o);
> 
> Thanks,
> Andrus
> 
> 
>> On Oct 24, 2025, at 9:05 AM, Ricardo Parada <[email protected]> wrote:
>> 
>> Good morning,
>> 
>> I’m looking for the equivalent of the following EOF code:
>> 
>> var obj = EOUtilities.faultWithPrimaryKeyValue(editingContext, entityName, 
>> id);
>> 
>> 
>> What I have so far is:
>> 
>> var objClass = 
>> oc.getEntityResolver().getClassDescriptor(objEntityName).getObjectClass();
>> var obj = SelectById.query(objClass, id)
>>       .localCache()
>>       .selectOne(oc);
>> 
>> But it seems to fetch the object the first time even though the object 
>> already exists in the object context.
>> 
>> Thanks in advance,
>> Ricardo Parada
>> 
> 

Reply via email to