You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Amedeo Mantica <am...@me.com> on 2017/05/06 18:07:49 UTC

Issue with same entity relationship

Hi all,

I have setup a Table with self entity relationship (let say parent/children)

so in database I have along with other columns:

ID
PARENT_ID

set with relationship:




Code:

ObjectContext ec = databaseController.newContext();

        DCTest t1 = Cayenne.objectForPK(ec, DCTest.class, 1000000);
        DCTest t2 = Cayenne.objectForPK(ec, DCTest.class, 1000001);

        t1.setParent(t2);

        ec.commitChanges();


all other attributes of the objects get updated except parent/chindren relationship

Any idea ?
Thank you
Amedeo



Re: Issue with same entity relationship

Posted by Amedeo Mantica <am...@me.com>.
I swapped join keys, lol, forget this thread :)

> On 6 May 2017, at 20:29, Amedeo Mantica <am...@me.com> wrote:
> 
> Forgot to say. Cayenne 3.1.x
> 
> Sent from my iPhone
> 
>> On 6 May 2017, at 20:07, Amedeo Mantica <am...@me.com> wrote:
>> 
>> Hi all,
>> 
>> I have setup a Table with self entity relationship (let say parent/children)
>> 
>> so in database I have along with other columns:
>> 
>> ID
>> PARENT_ID
>> 
>> set with relationship:
>> 
>> <PastedGraphic-1.png>
>> 
>> 
>> Code:
>> 
>> ObjectContext ec = databaseController.newContext();
>> 
>>        DCTest t1 = Cayenne.objectForPK(ec, DCTest.class, 1000000);
>>        DCTest t2 = Cayenne.objectForPK(ec, DCTest.class, 1000001);
>> 
>>        t1.setParent(t2);
>> 
>>        ec.commitChanges();
>> 
>> 
>> all other attributes of the objects get updated except parent/chindren relationship
>> 
>> Any idea ?
>> Thank you
>> Amedeo
>> 
>> 


Re: Issue with same entity relationship

Posted by Amedeo Mantica <am...@me.com>.
Forgot to say. Cayenne 3.1.x

Sent from my iPhone

> On 6 May 2017, at 20:07, Amedeo Mantica <am...@me.com> wrote:
> 
> Hi all,
> 
> I have setup a Table with self entity relationship (let say parent/children)
> 
> so in database I have along with other columns:
> 
> ID
> PARENT_ID
> 
> set with relationship:
> 
> <PastedGraphic-1.png>
> 
> 
> Code:
> 
> ObjectContext ec = databaseController.newContext();
> 
>         DCTest t1 = Cayenne.objectForPK(ec, DCTest.class, 1000000);
>         DCTest t2 = Cayenne.objectForPK(ec, DCTest.class, 1000001);
> 
>         t1.setParent(t2);
> 
>         ec.commitChanges();
> 
> 
> all other attributes of the objects get updated except parent/chindren relationship
> 
> Any idea ?
> Thank you
> Amedeo
> 
>