private Object [ ] readIdentities ( Class pObjClass , Hashtable pMapping , Hashtable pWhere , ObjectMapper pOM ) throws SQLException { sCacheUn ++ ; // Build SQL query string if ( pWhere == null ) pWhere = new Hashtable ( ) ; String [ ] keys = new String [ pWhere . size ( ) ] ; int i = 0 ; for ( Enumeration en = pWhere . keys ( ) ; en . hasMoreElements ( ) ; i ++ ) { keys [ i ] = ( String ) en . nextElement ( ) ; } // Get SQL for reading identity column String sql = pOM . buildIdentitySQL ( keys ) + buildWhereClause ( keys , pMapping ) ; // Log? mLog . logDebug ( sql + " (" + pWhere + ")" ) ; // Prepare statement and set values PreparedStatement statement = mConnection . prepareStatement ( sql ) ; for ( int j = 0 ; j < keys . length ; j ++ ) { Object key = pWhere . get ( keys [ j ] ) ; if ( key instanceof Integer ) statement . setInt ( j + 1 , ( ( Integer ) key ) . intValue ( ) ) ; else if ( key instanceof BigDecimal ) statement . setBigDecimal ( j + 1 , ( BigDecimal ) key ) ; else statement . setString ( j + 1 , key . toString ( ) ) ; } // Execute query ResultSet rs = null ; try { rs = statement . executeQuery ( ) ; } catch ( SQLException e ) { mLog . logError ( sql + " (" + pWhere + ")" , e ) ; throw e ; } Vector result = new Vector ( ) ; // Map query to objects while ( rs . next ( ) ) { Object obj = null ; try { obj = pObjClass . newInstance ( ) ; } catch ( IllegalAccessException iae ) { iae . printStackTrace ( ) ; } catch ( InstantiationException ie ) { ie . printStackTrace ( ) ; } // Map it pOM . mapColumnProperty ( rs , 1 , pOM . getProperty ( pOM . getPrimaryKey ( ) ) , obj ) ; result . addElement ( obj ) ; } // Return array of identifiers return result . toArray ( ( Object [ ] ) Array . newInstance ( pObjClass , result . size ( ) ) ) ; }
Get an array containing Objects of type objClass with the identity values for the given class set .