hibernate Criteria中or和and的用法
- /s筛选去除无效数据
- /* detachedCriteria.add(
- Restrictions.or(
- Restrictions.like("chanpin", "冰箱", MatchMode.ANYWHERE),
- Restrictions.or(
- Restrictions.like("chanpin", "洗衣机", MatchMode.ANYWHERE),
- Restrictions.or(
- Restrictions.like("chanpin", "热水器", MatchMode.ANYWHERE),
- Restrictions.like("chanpin", "空调", MatchMode.ANYWHERE))))
- );
- */
- Disjunction dis=Restrictions.disjunction();
- dis.add(Restrictions.like("chanpin", "冰箱", MatchMode.ANYWHERE));
- dis.add(Restrictions.like("chanpin", "洗衣机", MatchMode.ANYWHERE));
- dis.add(Restrictions.like("chanpin", "热水器", MatchMode.ANYWHERE));
- dis.add(Restrictions.like("chanpin", "空调", MatchMode.ANYWHERE));
- detachedCriteria.add(dis);
- //e筛选去除无效数据
用来组合一组逻辑或【or】条件的方法
- Restrictions.disjunction();
用来组合一组逻辑与【and】条件的方法
- Restrictions.conjunction();
注释掉部分的代码,查询结果和下面的代码一样,如果针对一个字段写多个逻辑或条件的话,用下面的方式比较好。根据具体情况选择合适的方法。
hibernate Criteria中or和and的用法的更多相关文章
- hibernate criteria中Restrictions的用法
方法说明 方法 说明 Restrictions.eq = Restrictions.allEq 利用Map来进行多个等于的限制 Restrictions.gt > Restrictions.ge ...
- hibernate Criteria中多个or和and的用法 and ( or or)
/s筛选去除无效数据 /* detachedCriteria.add( Restrictions.or( Restrictions.like("chanpin", &qu ...
- 【hibernate criteria】hibernate中criteria的完整用法 转
---恢复内容开始--- 转自:http://www.360doc.com/content/090313/10/26262_2794855.html 1.Criteria Hibernate 设计了 ...
- Hibernate 注解中CascadeType用法汇总
这两天,参加一个课程设计,同时这个项目又作为一个模块镶嵌到其他项目中,考虑如此,应与原先的架构相同,因牵扯到留言和相互@功能,故数据库之间OneToOne,OneToMany,ManyToMany之风 ...
- Hibernate Criteria使用
hibernate中Criteria的完整用法 Criteria 是一个完全面向对象,可扩展的条件查询API,通过它完全不需要考虑数据库底层如何实现.SQL语句如何编写,是Hibernate框架的核心 ...
- Hibernate Criteria 查询使用
转载 http://blog.csdn.net/woshisap/article/details/6747466 Hibernate 设计了 CriteriaSpecification 作为 Crit ...
- Hibernate Session中的save(),update(),delete(),saveOrUpdate() 细粒度分析
Hibernate在对资料库进行操作之前,必须先取得Session实例,相当于JDBC在对资料库操作之前,必须先取得Connection实例, Session是Hibernate操作的基础,它不是设计 ...
- Hibernate类中集合的映射
1 pojo类集合属性的映射 在pojo类中定义集合属性. 1.1 List集合属性的映射 package org.guangsoft.pojo; import java.util.List; pu ...
- atitit. 统计功能框架的最佳实践(1)---- on hibernate criteria
atitit. 统计功能框架的最佳实践(1)---- on hibernate criteria 1. 关键字 1 2. 统计功能框架普通有有些条件选项...一个日期选项..一个日期类型(日,周,月份 ...
随机推荐
- mqtt client python example
This is a simple example showing how to use the [Paho MQTT Python client](https://eclipse.org/paho/c ...
- SubmittingPatches, SubmitChecklist and CodingStyle
How to Get Your Change Into the Linux Kernel or Care And Operation Of Your Linus Torvalds For a pers ...
- python--面向对象封装
from collectoins import namedtuple Point=namedtuple('point',['x','y']) t1=Point(1,2) print(t1.x) pri ...
- HTML5学习笔记简明版(9):变化的元素和属性
改变的元素(Element) 下面元素在HTML5里的使用方法稍作改动以便能在web里更好的使用或者起到更大作用: 没有href属性的a元素将显示成一个占位符,并且a元素内部如今支持flow cont ...
- hdu 3932 Groundhog Build Home
Groundhog Build Home Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- 小程序 富文本 的页面展示 json 数据处理 go-echo 为小程序提供feed流服务
go生成页面 返回给web-view {{define "DBHtmlCode"}} <!DOCTYPE html> <html lang="zh-cm ...
- it starts (“forks”) a new process for each connection.
PostgreSQL: Documentation: 10: 1.2. Architectural Fundamentals https://www.postgresql.org/docs/10/st ...
- mysql user password plugin
caching_sha2_passwordcaching_sha2_passwordcaching_sha2_passwordcaching_sha2_passwordcaching_sha2_pas ...
- Java Virtual Machine (JVM) objects 虚拟机实例的产生 退出 两种线程
Apache Spark is built around a distributed collection of immutable Java Virtual Machine (JVM) object ...
- A桶中有多少水?
如果你能算出桶中有多少水,我便许你下山去玩.有一天,老和尚让小和尚将A桶的水挑到B桶去,可是小和尚却想下山玩,不愿意挑水,老和尚便说:”如果你能够根据我的提示算出A桶中有多少升水,我便许你下山去玩.” ...