Class EntityRowMapper<T>

java.lang.Object
org.huiche.jdbc.mapper.row.EntityRowMapper<T>
Type Parameters:
T - 实体类型
All Implemented Interfaces:
RowMapper<T>

public final class EntityRowMapper<T> extends Object implements RowMapper<T>
实体类行转换器

结果集中为 NULL 的列不会写入属性,字段初始值会被保留; 结果集中不存在的列同样跳过。字段初始值不应作为数据库默认值的替代。

Author:
Maning
  • Method Details

    • of

      public static <T> EntityRowMapper<T> of(Class<T> clazz)
      创建实体类转换器
      Type Parameters:
      T - 实体类类型
      Parameters:
      clazz - 实体类
      Returns:
      转换器
    • map

      public T map(ResultSet rs, IndexMapper indexMapper, Configuration configuration) throws SQLException
      Description copied from interface: RowMapper
      将结果集转换实体
      Specified by:
      map in interface RowMapper<T>
      Parameters:
      rs - 结果集
      indexMapper - 列下标的映射,按列下标读取的场景为 null(单列转换与自定义转换)
      configuration - 配置
      Returns:
      实体
      Throws:
      SQLException - 原生SQL异常
    • type

      public Type type()
      Description copied from interface: RowMapper
      类型
      Specified by:
      type in interface RowMapper<T>
      Returns:
      类型