日期:2014-05-20 浏览次数:21144 次
@Test
public void testIterate() {
Session s = sf.getCurrentSession();
s.beginTransaction();
Query q = s.createQuery("from Category");
Iterator<Category> it = q.iterate();
while (it.hasNext()) {
Category c = it.next();
System.out.println(c.getId());
}
it = q.iterate();
while (it.hasNext()) {
Category c = it.next();
System.out.println(c.getId());
}
s.getTransaction().commit();
}