[ 
https://issues.apache.org/jira/browse/CAY-1000?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13036152#comment-13036152
 ] 

M.Sushma edited comment on CAY-1000 at 5/19/11 12:38 PM:
---------------------------------------------------------

// CayenneDataObject.java -- > addToManyTarget()

if (holder instanceof Collection) {

for (DataObject i : (Collection<DataObject>) holder) {

if (value.getObjectId() == i.getObjectId()) {

System.out.println("Object already added");

check = true;

break;

}

else {

check = false;

}

}

      was (Author: sushma):
    CayenneDataObject -- > addToManyTarget

if (holder instanceof Collection) {

for (DataObject i : (Collection<DataObject>) holder) {

if (value.getObjectId() == i.getObjectId()) {

System.out.println("Object already added");

check = true;

break;

}

else {

check = false;

}

}
  
> Duplicate items in list.
> ------------------------
>
>                 Key: CAY-1000
>                 URL: https://issues.apache.org/jira/browse/CAY-1000
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 1.2 branch, 2.0 branch, 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to