mybatis typeHandler不起作用

时间:2016-03-24 07:53:25

标签: java mybatis sqlmap typehandler

我有一个像这样的SQL

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

和像这样的resultMap

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

NameTypeHandler

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);
  }
}

但它从不适用于处理程序

我可以这样使用吗?

0 个答案:

没有答案