zoukankan      html  css  js  c++  java
  • Hibernate的hql常用语句整理汇总

    //普通查询

    hql = "from User";

    //条件查询 where

     hql = "from User where UserName='张三’";

    模糊查询 like

     hql = "from User where UserName like '%羽%'";

    // 逻辑条件查询 >

    hql = "from User c where c.createDate >'2011-08-08'";

    // 逻辑条件查询 between and 

    hql = "from User c where c.createDate between '2013-04-19' and '2046-04-19'";

    逻辑多条件查询and

    hql = "from User c where c.createDate between '2013-04-19' and '2046-04-19' and c.UserName like '%%'";

     // update 更新

     hql = "update User as c set c.createDate='2011-03-03' where c.UserType.UserTypeId=3";

    // delete删除

    hql = "delete from  User as c where c.createDate='2011-03-04'";

    // 多个属性查询 面向对象方式

    hql = "select new User(c.UserName,c.createDate) from  User as c";

     // 函数查询

    hql = "select count(*),max(c.createDate) from  User as c";

     // 排序

     hql = "from  User as c order by c.createDate desc";

    // 分组

    hql = "from  User as c group by c.UserType.UserTypeId";

     // inner join 查询结果为多个对象的集合

    hql = "from  User as c inner join c.UserType";

     // leftJoin 查询结果为多个对象的集合

    hql = "from  UserType as c left join c.Users";

     // rightJoin 查询结果为多个对象的集合

    hql = "from  UserType as c right join c.Users";

    // 使用子查询

     hql = "from  UserType as c where (select count(*) from c.Users)>0";

  • 相关阅读:
    js简单排序
    js希尔排序
    js直接插入排序
    大数运算
    IOC和AOP的理解 (持续更新)
    频发事件的缓存技巧
    执行上下文深入解析(Execution Context)
    二分
    HDU 3790 最短路径问题 (双重权值)
    浅谈Targan算法
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3031691.html
Copyright © 2011-2022 走看看