Re: Getting fault or object

Ricardo Parada <[email protected]> Sat, 25 Oct 2025 16:33:43 -0400
Newsgroups gmane.comp.java.cayenne.user
Message-ID <[email protected]>

Awesome, thank you for that code Andrus.=20

Ricardo Parada



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