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

From: Kevin Menard (kmenar..ervprise.com)
Date: Wed Mar 05 2008 - 11:01:15 EST

  • Next message: Kevin Menard (JIRA): "[jira] Commented: (CAY-1000) Duplicate items in list."

    On 3/5/08 10:43 AM, "Andrus Adamchik" <andru..bjectstyle.org> wrote:

    >
    > On Mar 5, 2008, at 5:39 PM, Kevin Menard (JIRA) wrote:
    >
    >> However, it is fairly trivial to show that a relationship mapped as
    >> a List can hold a duplicate.
    >
    > But the question then "is this a bug"? I don't think it is.

    I suppose that's the million dollar question. At the very least, the
    documentation is misleading. The correct behavior is another matter and is
    something that has come up before on the list.

    If the underlying list is supposed to represent the data rows, then I think
    it is a bug. In the example provided, if I commit the context, only one
    artist and one painting are going to be persisted. If in another context I
    perform a query and grab the same artist, its painting list will be
    different -- one element fewer.

    So, there's this incongruity between the data model contents and the object
    model contents. Ultimately, Cayenne does the right thing and shields a user
    from invalid duplicates, but not in the object model the user is working
    with.

    The issue gets a little more complicated when an entity has two
    relationships to another entity. I've seen duplicates appear in the
    following situation.

    Artist <-1--------*-- Painting
    Artist --1--------1-> Painting

    For instance, maybe an artist has a favorite painting, so that ID is stored
    in the Artist table. Otherwise, Paintings maintain mappings to Artists.
    Through a sequence of events similar to:

    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.

    There may be more going on there. I couldn't verify behavior with that
    simple example, but I think there is something going on there.

    -- 
    Kevin
    



    This archive was generated by hypermail 2.0.0 : Wed Mar 05 2008 - 11:01:53 EST