DetachedCriteria离线对象查调用多个or语句

/**
* @author czs
* @version 创建时间:2018年4月16日 下午10:07:00 
*/
@Repository
public class RegionDaoImpl extends BaseDaoImpl implements IRegionDao{


@SuppressWarnings("unchecked")
@Override
public List getListRegionByQ(String q) {
DetachedCriteria criteria = DetachedCriteria.forClass(BcRegion.class);


// 省  市  区  区域简码  城市简码都列入搜索范围
criteria.add(Restrictions.or(
Restrictions.like("province", "%" + q + "%"),
Restrictions.like("city", "%" + q + "%"),
Restrictions.like("district", "%" + q + "%"),
Restrictions.like("citycode", "%" + q + "%"),
Restrictions.like("shortcode", "%" + q + "%")
));

return (List) this.getHibernateTemplate().findByCriteria(criteria);
}


}

你可能感兴趣的:(DetachedCriteria离线对象查调用多个or语句)