You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Gene Wu <ge...@hotmail.com> on 2007/09/05 00:25:01 UTC

Collection or Set?

Hi all,

In OpenJPA's user manual, it recommends Set instead of Collection due to performance and scalability.

I am just curious if I define the field in Collection type and initialize it with a Set instance. Any thing difference from keep it blank.

For example:

Collection<Entity> entities = new HashSet();

v.s.

Set<Entity> entities;

v.s.

Collection<Entity> entities;(it might be the worst case) 


Any idea and suggestion.

Thanks

Gene.

_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

Re: Collection or Set?

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

I believe that it's the field declaration that matters. You might be
able to get away with an @Type annotation, but that's pretty much the
same anyways.

Why does it matter what the field is declared as, btw? If you're using
field access and want to expose the field as a Collection, you could
always just define a getter that returns a Collection instead of a
Set.

-Patrick

On 9/4/07, Gene Wu <ge...@hotmail.com> wrote:
> Hi all,
>
> In OpenJPA's user manual, it recommends Set instead of Collection due to performance and scalability.
>
> I am just curious if I define the field in Collection type and initialize it with a Set instance. Any thing difference from keep it blank.
>
> For example:
>
> Collection<Entity> entities = new HashSet();
>
> v.s.
>
> Set<Entity> entities;
>
> v.s.
>
> Collection<Entity> entities;(it might be the worst case)
>
>
> Any idea and suggestion.
>
> Thanks
>
> Gene.
>
> _________________________________________________________________
> Explore the seven wonders of the world
> http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE


-- 
Patrick Linskey
202 669 5907