You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@polygene.apache.org by Niclas Hedhman <ni...@hedhman.org> on 2017/06/15 07:54:16 UTC

ManyAssociation a List or a Set?

Gang,

I found a quite serious bug in DefaultNamedAssociation, but since
MapEntityStore didn't user the "UPDATED" information about an entity, it
didn't manifest itself other than in the Preference and Cassandra ES
implementations, not using the MapES.

So, I went to check if the same fault was in the ManyAssociation and to my
surprise, I saw the following code;

if( references.contains( entityReference ) )
{
    return false;
}

references.add( i, entityReference );
entityState.markUpdated();
return true;


which means that it is a SET and not a LIST/SEQUENCE. But we have method
toList() and toSet() on ManyAssociation, as I think we originally intended
the internals to be a LIST.

Does anyone have any insight and opinion on this topic?


Cheers
-- 
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java

Re: ManyAssociation a List or a Set?

Posted by Niclas Hedhman <ni...@hedhman.org>.
ManyAssociation.toList() says this;

* <p>
* Multiple references to the same entity will be present multiple
times in the List, unlike {@link #toSet()}.
* The order in which the entities were added to this collection is preserved.
* </p>

This clearly says that (at some point) multiple instances of the same
reference was intended to be possible. Although that has not been the case
for quite a while (before 2009).



On Thu, Jun 15, 2017 at 3:54 PM, Niclas Hedhman <ni...@hedhman.org> wrote:

> Gang,
>
> I found a quite serious bug in DefaultNamedAssociation, but since
> MapEntityStore didn't user the "UPDATED" information about an entity, it
> didn't manifest itself other than in the Preference and Cassandra ES
> implementations, not using the MapES.
>
> So, I went to check if the same fault was in the ManyAssociation and to my
> surprise, I saw the following code;
>
> if( references.contains( entityReference ) )
> {
>     return false;
> }
>
> references.add( i, entityReference );
> entityState.markUpdated();
> return true;
>
>
> which means that it is a SET and not a LIST/SEQUENCE. But we have method
> toList() and toSet() on ManyAssociation, as I think we originally intended
> the internals to be a LIST.
>
> Does anyone have any insight and opinion on this topic?
>
>
> Cheers
> --
> Niclas Hedhman, Software Developer
> http://polygene.apache.org - New Energy for Java
>



-- 
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java