bootiful-sqltemplate-core/src/main/java/ninja/cero/sqltemplate/core/mapper/BeanMapper.java
@Override
    public T mapRow(ResultSet rs, int rowNumber) throws SQLException {
        Assert.state(this.mappedClass != null, "Mapped class was not specified");
        T mappedObject = BeanUtils.instantiate(this.mappedClass);
        BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(mappedObject);

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

        for (int index = 1; index <= columnCount; index++) {
            String column = JdbcUtils.lookupColumnName(metaData, index);

            String name = column.replaceAll(" ", "").toLowerCase();
            Object value = null;
            if (privateFields.containsKey(name)) {
                PropertyDescriptor pd = privateFields.get(name);
                value = getColumnValue(rs, index, pd.getPropertyType());
                if (logger.isDebugEnabled() && rowNumber == 0) {
                    logger.debug("Mapping column '" + column + "' to property '" + pd.getName() + "' of type " + pd.getPropertyType());
                }
                // TODO: care about assign null to primitive field. See BeanPropertyRowMapper
                bw.setPropertyValue(pd.getName(), value);
            } else if (publicFields.containsKey(name)) {
                Field field = this.publicFields.get(name);
                value = getColumnValue(rs, index, field.getType());
                if (logger.isDebugEnabled() && rowNumber == 0) {
                    logger.debug("Mapping column '" + column + "' to property '" + field.getName() + "' of type " + field.getType());
                }
                try {
                    field.set(mappedObject, value);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                }
            }
        }

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

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

        for (int index = 1; index <= columnCount; index++) {
            String column = JdbcUtils.lookupColumnName(metaData, index);

            String name = column.replaceAll(" ", "").toLowerCase();
            Object value = null;
            if (privateFields.containsKey(name)) {
                PropertyDescriptor pd = privateFields.get(name);
                value = getColumnValue(rs, index, pd.getPropertyType());
                if (logger.isDebugEnabled() && rowNumber == 0) {
                    logger.debug("Mapping column '" + column + "' to property '" + pd.getName() + "' of type " + pd.getPropertyType());
                }
                // TODO: care about assign null to primitive field. See BeanPropertyRowMapper
                bw.setPropertyValue(pd.getName(), value);
            } else if (publicFields.containsKey(name)) {
                Field field = this.publicFields.get(name);
                value = getColumnValue(rs, index, field.getType());
                if (logger.isDebugEnabled() && rowNumber == 0) {
                    logger.debug("Mapping column '" + column + "' to property '" + field.getName() + "' of type " + field.getType());
                }
                try {
                    field.set(mappedObject, value);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        return mappedObject;
    }
@ Override public T mapRow ( ResultSet rs , int rowNumber ) throws SQLException { Assert . state ( this . mappedClass != null , "Mapped class was not specified" ) ; T mappedObject = BeanUtils . instantiate ( this . mappedClass ) ; BeanWrapper bw = PropertyAccessorFactory . forBeanPropertyAccess ( mappedObject ) ; ResultSetMetaData metaData = rs . getMetaData ( ) ; int columnCount = metaData . getColumnCount ( ) ; for ( int index = 1 ; index <= columnCount ; index ++ ) { String column = JdbcUtils . lookupColumnName ( metaData , index ) ; String name = column . replaceAll ( " " , "" ) . toLowerCase ( ) ; Object value = null ; if ( privateFields . containsKey ( name ) ) { PropertyDescriptor pd = privateFields . get ( name ) ; value = getColumnValue ( rs , index , pd . getPropertyType ( ) ) ; if ( logger . isDebugEnabled ( ) && rowNumber == 0 ) { logger . debug ( "Mapping column '" + column + "' to property '" + pd . getName ( ) + "' of type " + pd . getPropertyType ( ) ) ; } // TODO: care about assign null to primitive field. See BeanPropertyRowMapper bw . setPropertyValue ( pd . getName ( ) , value ) ; } else if ( publicFields . containsKey ( name ) ) { Field field = this . publicFields . get ( name ) ; value = getColumnValue ( rs , index , field . getType ( ) ) ; if ( logger . isDebugEnabled ( ) && rowNumber == 0 ) { logger . debug ( "Mapping column '" + column + "' to property '" + field . getName ( ) + "' of type " + field . getType ( ) ) ; } try { field . set ( mappedObject , value ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } } } return mappedObject ; }
{@inheritDoc}
{