hibernate Criteria中or的用法

		//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】条件的方法 

Java代码   收藏代码
  1. Restrictions.disjunction();  



用来组合一组逻辑与【and】条件的方法 

Java代码   收藏代码
  1. Restrictions.conjunction();  

 

你可能感兴趣的:(Hibernate)