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

  

 

posted @ 2018-09-19 17:21  踏月而来  阅读(183)  评论(0编辑  收藏  举报