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>
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>
解决方案 »
- J2SE到J2EE怎么过渡
- 赚点生活费
- 关于用AXIS2生成WEBSERVICE客户端的问题
- 面试题2...
- 请问Struts中<logic:present name="XXX"> 如何使用?
- 如何开发项目
- 自己打算做点东西,请指教
- Jbuilder 2005 连oracle 的问题!在线等
- 求教一个异常:java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]过程 'test' 的请求失败,因为 'test'
- s:iterator相关问题
- Apache与Tomcat集成,运行DWR reverse-ajax的疑问
- 关于actionform的问题!
比如你的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>
只要po的属性名和sql字段名称对应就可以了另外queryForObject必须是单条记录
多条用queryForList