Mybatis使用时间段查询一直为空;
原因:
Map<String,Object> map=new HashMap<String,Object>(); map.put("beginTime",beginTime); map.put("endTime",endTime); map.put("staruserId",staruserId); map.put("pageSize",pageSize); map.put("pageNum",pageNum); List<BusinessLog> businessLogList=businessLogMapper.getUserBuyRecordByTime(map);
<select id="getUserBuyRecordByTime" resultType="com.xingyou.common.po.BusinessLog" parameterType="java.util.Map"> select Top ${pageSize} create_date createDate,produce_name produceName,order_number orderNumber,pay_credit payCredit from business_log where create_date BETWEEN #{beginTime} and #{endTime} </select>
实现类中map的key值和maper.xml调用的参数名称不一致,由于#{}只是占位符,所以没有对应也不报错,前面一直尝试是不是mybatis不能传字符串类型,将时间参数改成date类型不行,改成时间戳类型(long)还是不行,把#号改成$号就会报错
记在:map中的key一定要和mapper.xml中使用的参数名称一致