hql语句分批读取数据

List<String> list=new ArrayList<>();
List<String> list1=new ArrayList<>();
for (int i = 0; i==0 || list1.size()>=1 ; i+=10000) {
list1 = getSession().createQuery("SELECT xxxx FROM xxxx").setFirstResult(i).setMaxResults(10000).list();
if (list1.size()>=1) { //说明有记录
Iterator<String> ss=list1.iterator();
while (ss.hasNext()) {
String string = (String) ss.next();
list.add(string);
}
}else{
break;
}
}
return list;

你可能感兴趣的:(HQL)