You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Andrey Razumovsky <ra...@gmail.com> on 2009/07/10 10:20:19 UTC

Re: Circle references

>
> This is what Cayenne does. So there is really no cycle, and Cayenne still
> can't guess the order, this may be a bug.
>

Hi Andrus,

Unfortunately, this is not true. In AshwoodEntitySorter, all entities in
circle are put to same ComponentRecord. Existence of instances of all
entities in circle So their comparison at commit brings 0. Therefore records
will be inserted in the same order they are registered in context (I'm not
sure, or maybe the order is just unpredictable). So this causes an insertion
error:

Imagine references avaliable A->B->C->A

1. Create dependant entity B
2. Create master entity A
3. b.setA(a)
4. Commit.

C is even never used.

Andrey

Re: Circle references

Posted by Andrey Razumovsky <ra...@gmail.com>.
Not finished a statement in the middle, I meant "Existence of instances of
all entities in circle is never used during commit"

2009/7/10 Andrey Razumovsky <ra...@gmail.com>

> This is what Cayenne does. So there is really no cycle, and Cayenne still
>> can't guess the order, this may be a bug.
>>
>
> Hi Andrus,
>
> Unfortunately, this is not true. In AshwoodEntitySorter, all entities in
> circle are put to same ComponentRecord. Existence of instances of all
> entities in circle So their comparison at commit brings 0. Therefore records
> will be inserted in the same order they are registered in context (I'm not
> sure, or maybe the order is just unpredictable). So this causes an insertion
> error:
>
> Imagine references avaliable A->B->C->A
>
> 1. Create dependant entity B
> 2. Create master entity A
> 3. b.setA(a)
> 4. Commit.
>
> C is even never used.
>
> Andrey
>
>
>

Re: Circle references

Posted by Andrus Adamchik <an...@objectstyle.org>.
I didn't write this code, but I recall there is at least an attempt  
there to order objects of the same type to address a resolvable cycle  
like the one you've mentioned. Not sure what the limitations are... 1  
step cycle maybe (a parent-child relationship to self), but I really  
have no idea without looking at the code.

Andrus


On Jul 10, 2009, at 11:47 AM, Andrey Razumovsky wrote:

> It is possible to handle the incomplete circle situation, but in  
> case of
> complete circle it becomes very very tricky. Imagine situation
> A1->B->C->A2
> The correct (and only) insert order is A2, C, B, A1. But Cayenne can  
> never
> support this currently, because it is insering all records of one  
> entity at
> once (?).
>
> 2009/7/10 Andrus Adamchik <an...@objectstyle.org>
>
>> Ok, so seems like my understanding is matching yours. Looks like a  
>> bug.
>>
>> Andrus
>>
>>
>> On Jul 10, 2009, at 11:36 AM, Andrey Razumovsky wrote:
>>
>> //dev
>>> There is no cycle between CDO, but there is cycle in DataMap between
>>> DbEntities. AshwoodEntitySorter sorts entities that were changed,  
>>> not data
>>> objects. For entities in same circle comparison result is zero
>>>
>>> 2009/7/10 Andrus Adamchik <an...@objectstyle.org>
>>>
>>> Let me see if I get this right... In this example there is  
>>> obviously no
>>>> closed cycle. So you are saying AshwoodEntitySorter still assumes  
>>>> there
>>>> is
>>>> one, and gives up on ordering? Then this is a bug.
>>>>
>>>> Andrus
>>>>
>>>>
>>>>
>>>> On Jul 10, 2009, at 11:20 AM, Andrey Razumovsky wrote:
>>>>
>>>> Imagine references avaliable A->B->C->A
>>>>
>>>>>
>>>>> 1. Create dependant entity B
>>>>> 2. Create master entity A
>>>>> 3. b.setA(a)
>>>>> 4. Commit.
>>>>>
>>>>> C is even never used.
>>>>>
>>>>>
>>>>
>>>>
>>


Re: Circle references

Posted by Andrey Razumovsky <ra...@gmail.com>.
It is possible to handle the incomplete circle situation, but in case of
complete circle it becomes very very tricky. Imagine situation
A1->B->C->A2
The correct (and only) insert order is A2, C, B, A1. But Cayenne can never
support this currently, because it is insering all records of one entity at
once (?).

2009/7/10 Andrus Adamchik <an...@objectstyle.org>

> Ok, so seems like my understanding is matching yours. Looks like a bug.
>
> Andrus
>
>
> On Jul 10, 2009, at 11:36 AM, Andrey Razumovsky wrote:
>
>  //dev
>> There is no cycle between CDO, but there is cycle in DataMap between
>> DbEntities. AshwoodEntitySorter sorts entities that were changed, not data
>> objects. For entities in same circle comparison result is zero
>>
>> 2009/7/10 Andrus Adamchik <an...@objectstyle.org>
>>
>>  Let me see if I get this right... In this example there is obviously no
>>> closed cycle. So you are saying AshwoodEntitySorter still assumes there
>>> is
>>> one, and gives up on ordering? Then this is a bug.
>>>
>>> Andrus
>>>
>>>
>>>
>>> On Jul 10, 2009, at 11:20 AM, Andrey Razumovsky wrote:
>>>
>>> Imagine references avaliable A->B->C->A
>>>
>>>>
>>>> 1. Create dependant entity B
>>>> 2. Create master entity A
>>>> 3. b.setA(a)
>>>> 4. Commit.
>>>>
>>>> C is even never used.
>>>>
>>>>
>>>
>>>
>

Re: Circle references

Posted by Andrus Adamchik <an...@objectstyle.org>.
Ok, so seems like my understanding is matching yours. Looks like a bug.

Andrus

On Jul 10, 2009, at 11:36 AM, Andrey Razumovsky wrote:

> //dev
> There is no cycle between CDO, but there is cycle in DataMap between
> DbEntities. AshwoodEntitySorter sorts entities that were changed,  
> not data
> objects. For entities in same circle comparison result is zero
>
> 2009/7/10 Andrus Adamchik <an...@objectstyle.org>
>
>> Let me see if I get this right... In this example there is  
>> obviously no
>> closed cycle. So you are saying AshwoodEntitySorter still assumes  
>> there is
>> one, and gives up on ordering? Then this is a bug.
>>
>> Andrus
>>
>>
>>
>> On Jul 10, 2009, at 11:20 AM, Andrey Razumovsky wrote:
>>
>> Imagine references avaliable A->B->C->A
>>>
>>> 1. Create dependant entity B
>>> 2. Create master entity A
>>> 3. b.setA(a)
>>> 4. Commit.
>>>
>>> C is even never used.
>>>
>>
>>


Re: Circle references

Posted by Andrey Razumovsky <ra...@gmail.com>.
//dev
There is no cycle between CDO, but there is cycle in DataMap between
DbEntities. AshwoodEntitySorter sorts entities that were changed, not data
objects. For entities in same circle comparison result is zero

2009/7/10 Andrus Adamchik <an...@objectstyle.org>

> Let me see if I get this right... In this example there is obviously no
> closed cycle. So you are saying AshwoodEntitySorter still assumes there is
> one, and gives up on ordering? Then this is a bug.
>
> Andrus
>
>
>
> On Jul 10, 2009, at 11:20 AM, Andrey Razumovsky wrote:
>
>  Imagine references avaliable A->B->C->A
>>
>> 1. Create dependant entity B
>> 2. Create master entity A
>> 3. b.setA(a)
>> 4. Commit.
>>
>> C is even never used.
>>
>
>

Re: Circle references

Posted by Andrus Adamchik <an...@objectstyle.org>.
Let me see if I get this right... In this example there is obviously  
no closed cycle. So you are saying AshwoodEntitySorter still assumes  
there is one, and gives up on ordering? Then this is a bug.

Andrus


On Jul 10, 2009, at 11:20 AM, Andrey Razumovsky wrote:

> Imagine references avaliable A->B->C->A
>
> 1. Create dependant entity B
> 2. Create master entity A
> 3. b.setA(a)
> 4. Commit.
>
> C is even never used.