public static void createT_Selection(int AD_PInstance_ID,Collection<Integer> selection,String trxName){
  StringBuffer insert=new StringBuffer();
  insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
  int counter=0;
  for (  Integer selectedId : selection) {
    counter++;
    if (counter > 1)     insert.append(" UNION ");
    insert.append("SELECT ");
    insert.append(AD_PInstance_ID);
    insert.append(", ");
    insert.append(selectedId);
    insert.append(" FROM DUAL ");
    if (counter >= 1000) {
      DB.executeUpdateEx(insert.toString(),trxName);
      insert=new StringBuffer();
      insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
      counter=0;
    }
  }
  if (counter > 0) {
    DB.executeUpdateEx(insert.toString(),trxName);
  }
}

public static void createT_Selection ( int AD_PInstance_ID , Collection < Integer > selection , String trxName ) { StringBuffer insert = new StringBuffer ( ) ; insert . append ( "INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) " ) ; int counter = 0 ; for ( Integer selectedId : selection ) { counter ++ ; if ( counter > 1 ) insert . append ( " UNION " ) ; insert . append ( "SELECT " ) ; insert . append ( AD_PInstance_ID ) ; insert . append ( ", " ) ; insert . append ( selectedId ) ; insert . append ( " FROM DUAL " ) ; if ( counter >= 1000 ) { DB . executeUpdateEx ( insert . toString ( ) , trxName ) ; insert = new StringBuffer ( ) ; insert . append ( "INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) " ) ; counter = 0 ; } } if ( counter > 0 ) { DB . executeUpdateEx ( insert . toString ( ) , trxName ) ; } }
create persistent selection in t_selection table
