package one; import java.util.Iterator; import java.util.List; import org.hibernate.LockMode; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; public class Demo2 { public static void main(String[] args) { Configuration config=new Configuration().configure(); SessionFactory sf=config.buildSessionFactory(); Session session=sf.openSession(); Transaction trans=null; String sql="from Employee as e"; Query query=session.createQuery(sql); query.setLockMode("e",LockMode.UPGRADE); // query.setLockMode(“user”, LockMode.UPGRATE); query.setFirstResult(2); query.setMaxResults(5); List listEmployee=query.list(); Iterator iter=listEmployee.iterator(); while(iter.hasNext()){ Employee empTemp=(Employee)iter.next(); System.out.println(empTemp.getAddress()); // Object []obj=(Object[])iter.next(); // System.out.println(obj[0]); // System.out.println(obj[1]); } } }