Kevin Menard reassigned CAY-1000:
---------------------------------
Assignee: Kevin Menard (was: Andrus Adamchik)
> Duplicate items in list.
> ------------------------
>
> Key: CAY-1000
> URL: https://issues.apache.org/cayenne/browse/CAY-1000
> Project: Cayenne
> Issue Type: Bug
> Components: Cayenne Core Library
> Affects Versions: 1.2 [STABLE], 2.0 [STABLE], 3.0
> Reporter: Kevin Menard
> Assignee: Kevin Menard
>
> According to the documentation on relationships (http://cayenne.apache.org/doc/relationships.html):
> "Considering that Cayenne Lists are internally managed as ordered Sets, and are not allowed to contain the same object more than once, you may want to avoid modeling relationships as Sets at all, unless the object public interface requirements warrant that."
> However, it is fairly trivial to show that a relationship mapped as a List can hold a duplicate. For example, the following test will fail:
> public void testDuplicateAdd() {
> Artist artist = (Artist) ctxt.newObject("Artist");
> artist.setArtistName("a name");
> assertTrue(artist.getPaintingArray().isEmpty());
> // Add a single painting to the artist.
> 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);
> assertEquals(1, artist.getPaintingArray().size());
> }
> The last assertion fails because the array size will actually be 2.
-- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
This archive was generated by hypermail 2.0.0 : Wed Mar 05 2008 - 10:40:31 EST