private static String buildMultipleIdQuery(Set<Long> ids,String key){
  StringBuilder selection=new StringBuilder();
  boolean first=true;
  for (  Long id : ids) {
    if (first) {
      first=false;
    }
 else {
      selection.append(" OR ");
    }
    selection.append(key);
    selection.append("=");
    selection.append(id);
  }
  return selection.toString();
}

private static String buildMultipleIdQuery ( Set < Long > ids , String key ) { StringBuilder selection = new StringBuilder ( ) ; boolean first = true ; for ( Long id : ids ) { if ( first ) { first = false ; } else { selection . append ( " OR " ) ; } selection . append ( key ) ; selection . append ( "=" ) ; selection . append ( id ) ; } return selection . toString ( ) ; }
build a selection over a set of row ids
