Buggy code:
public class QueryBuilder { private final Map < String , List < Integer > > indexMap ; private final Connection connection ; private final PreparedStatement statement ; private QueryBuilder ( DataSource dataSource , String query ) throws SQLException { } private static String parse ( String query , Map < String , List < Integer > > paramMap ) { } public static QueryBuilder create ( DataSource dataSource , String query ) throws SQLException { } private List < Integer > indexes ( String name ) { } public QueryBuilder setBoolean ( String name , boolean value ) throws SQLException { } public QueryBuilder setInteger ( String name , int value ) throws SQLException { } public QueryBuilder setLong ( String name , long value ) throws SQLException { } public QueryBuilder setDouble ( String name , double value ) throws SQLException { } public QueryBuilder setString ( String name , String value ) throws SQLException { } public QueryBuilder setDate ( String name , Date value ) throws SQLException { } public QueryBuilder setObject ( Object object ) throws SQLException { } private interface ResultSetProcessor < T > { public void process ( T object , ResultSet resultSet ) throws SQLException { } } public < T extends Factory > T executeQuerySingle ( T prototype ) throws SQLException { } public < T extends Factory > Collection < T > executeQuery ( T prototype ) throws SQLException { List < T > result = new LinkedList < T > ( ) ; try { ResultSet resultSet = statement . executeQuery ( ) ; try { ResultSetMetaData resultMetaData = resultSet . getMetaData ( ) ; List < QueryBuilder . ResultSetProcessor < T > > processors = new LinkedList < QueryBuilder . ResultSetProcessor < T > > ( ) ; Method [ ] methods = prototype . getClass ( ) . getMethods ( ) ; for ( final Method method : methods ) { if ( ( method . getName ( ) . startsWith ( "set" ) ) && ( ( method . getParameterTypes ( ) . length ) == 1 ) ) { final String name = method . getName ( ) . substring ( 3 ) ; boolean column = false ; for ( int i = 1 ; i <= ( resultMetaData . getColumnCount ( ) ) ; i ++ ) { <START_BUG> if ( name . equalsIgnoreCase ( resultMetaData . getColumnName ( i ) ) ) { <END_BUG> column = true ; break ; } } if ( ! column ) { continue ; } Class < ? > parameterType = method . getParameterTypes ( ) [ 0 ] ; if ( parameterType . equals ( boolean . class ) ) { processors . add ( new QueryBuilder . ResultSetProcessor < T > ( ) { @ Override public void process ( T object , ResultSet resultSet ) throws SQLException { try { method . invoke ( object , resultSet . getBoolean ( name ) ) ; } catch ( IllegalAccessException error ) { } catch ( InvocationTargetException error ) { } } } ) ; } else if ( parameterType . equals ( int . class ) ) { processors . add ( new QueryBuilder . ResultSetProcessor < T > ( ) { @ Override public void process ( T object , ResultSet resultSet ) throws SQLException { try { method . invoke ( object , resultSet . getInt ( name ) ) ; } catch ( IllegalAccessException error ) { } catch ( InvocationTargetException error ) { } } } ) ; } else if ( parameterType . equals ( long . class ) ) { processors . add ( new QueryBuilder . ResultSetProcessor < T > ( ) { @ Override public void process ( T object , ResultSet resultSet ) throws SQLException { try { method . invoke ( object , resultSet . getLong ( name ) ) ; } catch ( IllegalAccessException error ) { } catch ( InvocationTargetException error ) { } } } ) ; } else if ( parameterType . equals ( double . class ) ) { processors . add ( new QueryBuilder . ResultSetProcessor < T > ( ) { @ Override public void process ( T object , ResultSet resultSet ) throws SQLException { try { method . invoke ( object , resultSet . getDouble ( name ) ) ; } catch ( IllegalAccessException error ) { } catch ( InvocationTargetException error ) { } } } ) ; } else if ( parameterType . equals ( String . class ) ) { processors . add ( new QueryBuilder . ResultSetProcessor < T > ( ) { @ Override public void process ( T object , ResultSet resultSet ) throws SQLException { try { method . invoke ( object , resultSet . getString ( name ) ) ; } catch ( IllegalAccessException error ) { } catch ( InvocationTargetException error ) { } } } ) ; } else if ( parameterType . equals ( Date . class ) ) { processors . add ( new QueryBuilder . ResultSetProcessor < T > ( ) { @ Override public void process ( T object , ResultSet resultSet ) throws SQLException { try { method . invoke ( object , new Date ( resultSet . getTimestamp ( name ) . getTime ( ) ) ) ; } catch ( IllegalAccessException error ) { } catch ( InvocationTargetException error ) { } } } ) ; } } } while ( resultSet . next ( ) ) { T object = ( ( T ) ( prototype . create ( ) ) ) ; for ( QueryBuilder . ResultSetProcessor < T > processor : processors ) { processor . process ( object , resultSet ) ; } result . add ( object ) ; } } finally { resultSet . close ( ) ; } } finally { statement . close ( ) ;

Fix:
if ( name . equalsIgnoreCase ( resultMetaData . getColumnLabel ( i ) ) ) {