code: private Criteria buildPrefetchCriteriaSingleKey(Collection ids, String fkCol, String itemFkCol,
              FieldDescriptor itemPkField)
      {
          Criteria crit = new Criteria();
          ArrayList values = new ArrayList(ids.size());
          Iterator iter = ids.iterator();
          Identity id;
  
          while (iter.hasNext())
          {
              id = (Identity) iter.next();
              values.add(id.getPrimaryKeyValues()[0]);
          }
  
          switch (values.size())
          {
              case 0 :
                  break;
              case 1 :
                  crit.addEqualTo(fkCol, values.get(0));
                  break;
              default :
                  // create IN (...) for the single key field
                  crit.addIn(fkCol, values);
                  break;
          }
  
          crit.addEqualToField(itemPkField.getAttributeName(), itemFkCol);
  
          return crit;
      }
docs: Build the prefetch criteria
  
  @param ids Collection of identities of M side
  @param fkCol indirection table fks to this class
  @param itemFkCol indirection table fks to item class
  @param itemPkField
  @return the Criteria