zoukankan      html  css  js  c++  java
  • HQL分页查询

    转自:https://blog.csdn.net/dwenxue/article/details/80460161

    【例】雇员信息


    分页查询
    (1)setFirstResult(int firstResult):设置开始检索的对象。

    (2)setMaxResults(int maxResults):设置每次检索返回的最大对象数。

    session=HibernateSessionFactory.getSession();
    String hql="from Employee";
    Query query=session.createQuery(hql);
    query.setFirstResult(0);
    query.setMaxResults(3);
    List<Employee>list=query.list();
    for(Employee emp:list){
    System.out.println(emp.getEmp_id()+" "+emp.getEmp_name()+" "+emp.getEmp_sex()+
    " "+emp.getEmp_birth()+" "+emp.getEmp_job()+" "+emp.getEmp_salary());
    }
    运行结果:


    ---------------------
    作者:云淡风轻58
    来源:CSDN
    原文:https://blog.csdn.net/dwenxue/article/details/80460161?utm_source=copy
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    FR #3题解
    L3-005. 垃圾箱分布
    L2-004. 这是二叉搜索树吗?
    L2-002. 链表去重
    L1-009. N个数求和
    L3-003. 社交集群
    L3-004. 肿瘤诊断
    L2-001. 紧急救援
    L3-002. 堆栈
    L2-007. 家庭房产
  • 原文地址:https://www.cnblogs.com/sharpest/p/9789970.html
Copyright © 2011-2022 走看看