Re: [jira] Created: (CAY-1000) Duplicate items in list.

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Mar 05 2008 - 11:19:27 EST

  • Next message: Andrus Adamchik: "Re: [jira] Created: (CAY-1000) Duplicate items in list."

    On Mar 5, 2008, at 6:01 PM, Kevin Menard wrote:
    > artist.addToPaintings(painting);
    > artist.setFavorite(painting);
    >
    > I've seen duplicates appear such that artist.getPaintings() has two
    > entries
    > even though it's associated only with a single painting.

    If that's the case, that would be a bug.

    >> Painting painting = (Painting) ctxt.newObject("Painting");
    >> painting.setPaintingTitle("a painting");
    >> artist.addToPaintingArray(painting);
    >> assertEquals(1, artist.getPaintingArray().size());
    >> // Now add the exact same painting. Cayenne should detect
    >> the duplicate and not actually add it.
    >> artist.addToPaintingArray(painting);
    >

    The above is not a bug, but maybe we can document the behavior a
    little better (and it would be insane to scan the list every time in
    search of duplicates). Here is my thinking:

    1. Cayenne only guarantees that *Cayenne* will return no duplicates
    for to-many. If a user explicitly wants a list to contain duplicates,
    that's his problem.

    2. If the user wants the framework to ensure no duplicates, no matter
    what, he should use a Set.

    (and I agree - let's change the docs to make it more clear)

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Mar 05 2008 - 11:20:00 EST