When using mybatis I have a question about reading data which is selected into one given time interval. In the xml file, I write like:
<select id="getRecord" parameterType="java.util.Map" resultType="com.domain.record">
select METHOD method, TIME_STAMP timeStamp
from RECORD
where TIME_STAMP BETWEEN #{startTime} AND #{endTime}
</select>
in another file, I write like this:
public List<Record> getRecord(String starttime, String endtime) {
Map<String, String> map = new LinkedHashMap<String, String>();
String startTime= "\'"+starttime + "\'";
String endTime= "\'"+endtime + "\'";
map.put("startTime",startTime);
map.put("endTime", endTime);
List<APIServerRecord> listRes=apiServerRecordMapper.getAPIServerRecord(map);
return listRes;
}
It does not work. The size of listRes
is zero and I'sure that there are many records and it should not be zero. And I'm sure that other sql statements in xml file is work. Meanwhile, if I give the time directly in xml file like the following code, it works:
<select id="getRecord" parameterType="java.util.Map" resultType="com.domain.record">
select METHOD method, TIME_STAMP timeStamp
from RECORD
where TIME_STAMP BETWEEN '2013-06-18 12:11' AND '2013-06-18 12:16'
</select>
Could you tell me how to do it?