3

我有一个这样的sql

<select id="getData" parameterType="map" resultMap="dataMapper">
  SELECT name FROM TABLE
</select>

和这样的结果图

<resultMap id="dataMapper" type="String">
    <result property="data" column="name" typeHandler="xxx.NameTypeHandler" />
</resultMap>

名称类型处理程序

public class NameTypeHandler implements TypeHandler<String> {

  @Override
  public void setParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException {
    // TODO Auto-generated method stub
  }

  @Override
  public String getResult(ResultSet rs, String columnName) throws SQLException {
    return "test" + rs.getString(columnName);
  }

  @Override
  public String getResult(ResultSet rs, int columnIndex) throws SQLException {
    return "test" + rs.getString(columnIndex);
  }

  @Override
  public String getResult(CallableStatement cs, int columnIndex) throws SQLException {
    return "test" + cs.getString(columnIndex);
  }
}

但它从不与处理程序一起使用

我可以这样使用吗?

4

0 回答 0