类 SingleColumnRowMapper<T>

    • 方法详细资料

      • setRequiredType

        public void setRequiredType​(Class<T> requiredType)
        Set the type that each result object is expected to match.

        If not specified, the column value will be exposed as returned by the JDBC driver.

      • getColumnValue

        protected Object getColumnValue​(ResultSet rs,
                                        int index)
                                 throws SQLException
        Retrieve a JDBC object value for the specified column, using the most appropriate value type. Called if no required type has been specified.

        The default implementation delegates to JdbcUtils.getResultSetValue(), which uses the ResultSet.getObject(index) method. Additionally, it includes a "hack" to get around Oracle returning a non-standard object for their TIMESTAMP datatype. See the JdbcUtils#getResultSetValue() javadoc for details.

        参数:
        rs - is the ResultSet holding the data
        index - is the column index
        返回:
        the Object value
        抛出:
        SQLException - in case of extraction failure
        另请参阅:
        JdbcUtils.getResultSetValue(java.sql.ResultSet, int)
      • convertValueToRequiredType

        protected Object convertValueToRequiredType​(Object value,
                                                    Class<?> requiredType)
        Convert the given column value to the specified required type. Only called if the extracted column value does not match already.

        If the required type is String, the value will simply get stringified via toString(). In case of a Number, the value will be converted into a Number, either through number conversion or through String parsing (depending on the value type).

        参数:
        value - the column value as extracted from getColumnValue() (never null)
        requiredType - the type that each result object is expected to match (never null)
        返回:
        the converted value
        另请参阅:
        getColumnValue(java.sql.ResultSet, int, Class)
      • newInstance

        public static <T> SingleColumnRowMapper<T> newInstance​(Class<T> requiredType)
        Static factory method to create a new SingleColumnRowMapper (with the required type specified only once).
        参数:
        requiredType - the type that each result object is expected to match
        从以下版本开始:
        4.1