title: duplicate elements in object list
body: <p>I have a query in my code, where it search one object for multiple ids. In table <code>PreparationPhytoterapic</code> contains the following fields: <code>phytoterapicItem_id</code> (foreign key), <code>preparationItem_id</code> (foreign key) and <code>id</code>. The problem is that when a <code>preparationItem_id</code> contains more than one entry, it is added again in the list.</p>
  
  <p>I try use <code>if(!listPreparations.contains(preparationContents2.get(0)))</code> but doesn't work.</p>
  
  <p>Any idea?</p>
  
  <pre><code>        preparationphytoterapicDao = getHelper().getPreparationPhytoterapicDao();
          QueryBuilder&lt;PreparationPhytoterapic, Integer&gt; queryBuilder2 = 
              preparationphytoterapicDao.queryBuilder();
          Where&lt;PreparationPhytoterapic, Integer&gt; where2 = queryBuilder2.where();
          SelectArg selectArg = new SelectArg();
          where2.eq("phytoterapicItem_id", selectArg);
          PreparedQuery&lt;PreparationPhytoterapic&gt; preparedQuery2 = queryBuilder2.prepare();
          List&lt;PreparationPhytoterapic&gt; preparationphytoterapics;
          QueryBuilder&lt;PreparationContent, Integer&gt; queryBuilder3 = 
              preparationContentDao.queryBuilder();
          Where&lt;PreparationContent, Integer&gt; where3 = queryBuilder3.where();
          SelectArg selectArg2 = new SelectArg();
          where3.eq("id", selectArg2);
          PreparedQuery&lt;PreparationContent&gt; preparedQuery3 = queryBuilder3.prepare();
          List&lt;PreparationContent&gt; preparationContents2;
          for(int j = 0; j &lt; listPhytoterapics.size(); j++) {
              selectArg.setValue(listPhytoterapics.get(j).getPhytoterapicItem().getId());
              preparationphytoterapics = preparationphytoterapicDao.query(preparedQuery2);
              if(preparationphytoterapics.size() != 0) {
                  for(int k = 0; k &lt; preparationphytoterapics.size(); k++) {
                      selectArg2.setValue(preparationphytoterapics.get(k).getPreparationItem().getId());
                      preparationContents2 = preparationContentDao.query(preparedQuery3);
                      if(!listPreparations.contains(preparationContents2.get(0)))
                          listPreparations.add(preparationContents2.get(0));
                  }
              }
  </code></pre>