Hibernate 查询 Restrictions 类使用

实例参考地址:

http://blog.163.com/zhaowenchao_vip/blog/static/1715151442012411101741608/

(1)比较运算符( propertyName 是指Java对象的属性名称而不是数据库表对象的列名 

HQL运算符 QBC运算符 含义

           1.= Restrictions.eq(String propertyName,Object value) 等于 

                        

           2.<> Restrictions.not(Exprission.eq()) 不等于

           3.> Restrictions.gt() 大于

           4.>= Restrictions.ge() 大于等于

           5.< Restrictions.lt() 小于

           6.<= Restrictions.le() 小于等于

           7.is null Restrictions.isnull() 等于空值

           8.is not null Restrictions.isNotNull() 非空值

           9.like Restrictions.like() 字符串模式匹配

                    MatchMode.EXACT --> 字符串精确匹配.相当于"like 'value'"

                    MatchMode.ANYWHERE --> 字符串在中间匹配.相当于"like '%value%'"

                    MatchMode.START --> 字符串在最前面的位置.相当于"like 'value%'"

 

                    MatchMode.END --> 字符串在最后面的位置.相当于"like '%value'"

                   A:Restrictions.like('Entity property','real value',MatchMode.START

          10.and Restrictions.and() 逻辑与

          11.and Restrictions.conjunction() 逻辑与

          12.or Restrictions.or() 逻辑或

          13.or Restrictions.disjunction() 逻辑或

          14.not Restrictions.not() 逻辑非

          15.in(列表) Restrictions.in() 等于列表中的某一个值

          16.ont in(列表) Restrictions.not(Restrictions.in())不等于列表中任意一个值

          17.between x and y Restrictions.between() 闭区间xy中的任意值

          18.not between x and y Restrictions.not(Restrictions..between()) 小于值X或者大于值y

猜你喜欢

转载自lihongtai.iteye.com/blog/2163646