1.定义一个pojopackage test;
public class Type{
    private String type;
    private int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
2.在ibatis的sqlmap中加入:<resultMap id="Type" class="test.Type">
    <result property="type" javaType="string" jdbcType="VARCHAR" column="TYPE" />
    <result property="count" javaType="long" jdbcType="NUMERIC" column="COUNT" nullValue="-9999999999" />
</resultMap><select id="getCountByType" resultMap="Type"> 
select TXN_TYPE ,count(txn_type) as COUNT  from card_opr group by txn_type; 
</select>

解决方案 »

  1.   

    对了,resultMap的值要加namespace的
    比如你的sqlmap的namespace="test"
    那么<select id="getCountByType" resultMap="test.Type"> 
    select TXN_TYPE ,count(txn_type) as COUNT  from card_opr group by txn_type; 
    </select>
      

  2.   

    简单点可以用resultClass="map"select id不能相同
    只要po的属性名和sql字段名称对应就可以了另外queryForObject必须是单条记录
    多条用queryForList