涉及到多表查询,使用的是原生sql语句,返回值是list,但list装载的是Object对象,并不是实体对象,为了使用方便,添加了多表实体类,以下是关键代码
pageResearch() 是分页查询方法,limit是每页显示记录数,begin是第几页
List rockList = rockManager.pageResearch(hqlString.toString(), begin, limit);
List<RockObjectValue> rockData = new LinkedList();
if(rockList !=null && rockList.size() > 0){
for(int i = 0; i < rockList.size(); i++ ){
Object[] object = (Object[])rockList.get(i);
String code = (String)object[0];
Date monitordate = (Date)object[1];
Date creatdate = (Date)object[2];
double value = (double)object[3];
double sinkvalue = (double)object[4];
double coraccuvalue = (double)object[5];
double sinkspeed = (double)object[6];
int interval = (int)object[7];
String testperson = (String)object[8];
RockObjectValue rockObjectValue = new RockObjectValue();
rockObjectValue.setCode(code);
rockObjectValue.setMonitordate(monitordate);
rockObjectValue.setCreatdate(creatdate);
rockObjectValue.setValue(value);
rockObjectValue.setSinkvalue(sinkvalue);
rockObjectValue.setCoraccuvalue(coraccuvalue);
rockObjectValue.setSinkspeed(sinkspeed);
rockObjectValue.setInterval(interval);
rockObjectValue.setTestperson(testperson);
rockData.add(rockObjectValue);
}
}