mybatis的xml映射文件

1,在进行统计查询时候,不想写映射的实体类,这时候设置返回的resultType类型是map

   <select id="getMap" resultType="java.util.Map" parameterType="java.util.Map" >

     select
count(*) as totalTimes ,sum(brushLong) as totalSecond
from xxxx where toothId = #{toothId,jdbcType=BIGINT}
and date(brushDate) = DATE_FORMAT(#{date,jdbcType=TIMESTAMP},'%Y-%m-%d') ; </select>

2 , 调用方法

	Map<String,Object> parms2 = new HashMap<String,Object>();
parms2.put("toothId", 10000);
parms2.put("date","2018-08-08");
Map object = (Map) toothDao.getMap(parms2);
String totalTimes = 0;
if(object.containsKey("totalTimes")){
totalTimes =object.get("totalTimes").toString();
}

  

上一篇:JavaWeb_day06_Filter过滤器


下一篇:2015年百度之星初赛(1) --- A 超级赛亚ACMer