@Override
    public T mapRow(ResultSet rs, int rowNumber) throws SQLException {
        Assert.state(this.mappedClass != null, "Mapped class was not specified");

        T mappedObject;
        try {
            mappedObject = mappedClass.newInstance();
        }
        catch(Exception ex) {
            throw new RuntimeException(ex);
        }

        ResultSetMetaData rsmd = rs.getMetaData();
        int columnCount = rsmd.getColumnCount();

        for (int index = 1; index <= columnCount; index++) {
            String column = JdbcUtils.lookupColumnName(rsmd, index);
            Field field = this.mappedFields.get(column.replaceAll(" ", ""));
            if (field != null) {
                Object value = getColumnValue(rs, index, field);
                if (logger.isTraceEnabled() && rowNumber == 0) {
                    logger.trace("Mapping column '" + column + "' to property '" +
                            field.getName() + "' of type " + field.getType());
                }
                try {
                    field.set(mappedObject, value);
                }
                catch (IllegalArgumentException e) {
                    if (value == null && primitivesDefaultedForNullValue) {
                        logger.debug("Intercepted IllegalArgumentException for row " + rowNumber +
                                " and column '" + column + "' with value " + value +
                                " when setting property '" + field.getName() + "' of type " + field.getType() +
                                " on object: " + mappedObject);
                    }
                    else {
                        throw e;
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }

        return mappedObject;
    }
@Override
    public T mapRow(ResultSet rs, int rowNumber) throws SQLException {
        Assert.state(this.mappedClass != null, "Mapped class was not specified");

        T mappedObject;
        try {
            mappedObject = mappedClass.newInstance();
        }
        catch(Exception ex) {
            throw new RuntimeException(ex);
        }

        ResultSetMetaData rsmd = rs.getMetaData();
        int columnCount = rsmd.getColumnCount();

        for (int index = 1; index <= columnCount; index++) {
            String column = JdbcUtils.lookupColumnName(rsmd, index);
            Field field = this.mappedFields.get(column.replaceAll(" ", ""));
            if (field != null) {
                Object value = getColumnValue(rs, index, field);
                if (logger.isTraceEnabled() && rowNumber == 0) {
                    logger.trace("Mapping column '" + column + "' to property '" +
                            field.getName() + "' of type " + field.getType());
                }
                try {
                    field.set(mappedObject, value);
                }
                catch (IllegalArgumentException e) {
                    if (value == null && primitivesDefaultedForNullValue) {
                        logger.debug("Intercepted IllegalArgumentException for row " + rowNumber +
                                " and column '" + column + "' with value " + value +
                                " when setting property '" + field.getName() + "' of type " + field.getType() +
                                " on object: " + mappedObject);
                    }
                    else {
                        throw e;
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }

        return mappedObject;
    }
@ Override public T mapRow ( ResultSet rs , int rowNumber ) throws SQLException { Assert . state ( this . mappedClass != null , "Mapped class was not specified" ) ; T mappedObject ; try { mappedObject = mappedClass . newInstance ( ) ; } catch ( Exception ex ) { throw new RuntimeException ( ex ) ; } ResultSetMetaData rsmd = rs . getMetaData ( ) ; int columnCount = rsmd . getColumnCount ( ) ; for ( int index = 1 ; index <= columnCount ; index ++ ) { String column = JdbcUtils . lookupColumnName ( rsmd , index ) ; Field field = this . mappedFields . get ( column . replaceAll ( " " , "" ) ) ; if ( field != null ) { Object value = getColumnValue ( rs , index , field ) ; if ( logger . isTraceEnabled ( ) && rowNumber == 0 ) { logger . trace ( "Mapping column '" + column + "' to property '" + field . getName ( ) + "' of type " + field . getType ( ) ) ; } try { field . set ( mappedObject , value ) ; } catch ( IllegalArgumentException e ) { if ( value == null && primitivesDefaultedForNullValue ) { logger . debug ( "Intercepted IllegalArgumentException for row " + rowNumber + " and column '" + column + "' with value " + value + " when setting property '" + field . getName ( ) + "' of type " + field . getType ( ) + " on object: " + mappedObject ) ; } else { throw e ; } } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; } } } return mappedObject ; }
Extract the values for all columns in the current row.
<p>Utilizes public setters and result set metadata.
@see java.sql.ResultSetMetaData
Extract the values for all columns in the current row . <p > Utilizes public setters and result set metadata .