日期:2014-05-17 浏览次数:20692 次
public List<NormalKaoQin> getNormalKaoQinList() {
Session s = this.getSession();
List list = s.createSQLQuery("select cio1.userid,cio1.checktime,cio2.checktime " +
"from checkinout cio1,checkinout cio2 " +
"where cio1.userid = cio2.userid " +
"and cio1.checktype='I' " +
"and cio2.checktype='O' " +
"and year(cio1.checktime) = year(cio2.checktime) " +
"and month(cio1.checktime) = month(cio2.checktime) " +
"and day(cio1.checktime) = day(cio2.checktime);").addEntity(NormalKaoQin.class).list();
return list;
}
for(int i = 0 ; i < list.size(); i ++){
/*
* 数组元素顺序跟sql中字段的顺序一致、从0开始
*/
Object[] objarr = (Object[])list.get(i);
System.out.println(objarr[0]); //cio1.userid
System.out.println(objarr[1]); //cio1.checktime
System.out.println(objarr[2]); //cio2.checktime
}