public static List < IdName > getParameterValues ( Connection con , QueryParameter qp , Map < String , QueryParameter > map , Map < String , Serializable > vals ) throws Exception { Map < String , Object > objVals = new HashMap < String , Object > ( ) ; for ( String key : vals . keySet ( ) ) { Serializable s = vals . get ( key ) ; if ( s instanceof Serializable [ ] ) { Serializable [ ] array = ( Serializable [ ] ) s ; Object [ ] objArray = new Object [ array . length ] ; for ( int i = 0 , size = array . length ; i < size ; i ++ ) { objArray [ i ] = array [ i ] ; } s = objArray ; } objVals . put ( key , s ) ; } QueryExecutor executor = null ; try { List < IdName > values = new ArrayList < IdName > ( ) ; Query query = new Query ( qp . getSource ( ) ) ; executor = new QueryExecutor ( query , map , objVals , con , false , false , false ) ; executor . setTimeout ( 10000 ) ; executor . setMaxRows ( 0 ) ; QueryResult qr = executor . execute ( ) ; //int count = qr.getRowCount(); // one or two columns in manual select source //for (int i = 0; i < count; i++) { while ( qr . hasNext ( ) ) { IdName in = new IdName ( ) ; in . setId ( ( Serializable ) qr . nextValue ( 0 ) ) ; if ( qr . getColumnCount ( ) == 1 ) { in . setName ( ( Serializable ) qr . nextValue ( 0 ) ) ; } else { in . setName ( ( Serializable ) qr . nextValue ( 1 ) ) ; } values . add ( in ) ; } return values ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; throw new Exception ( ex ) ; } finally { if ( executor != null ) { executor . close ( ) ; } } }
Get values for a dependent parameter sql All parent parameters must have the values in the map .