DetachedCriteria query = DetachedCriteria.forClass(entity.getClass());
//定义条件
Property PPadUrl = Property.forName("PPadUrl");
Property PBlink = Property.forName("PBlink");
Property PName = Property.forName("PName");
//逻辑或
Disjunction param = Restrictions.disjunction();
//条件插入
if(!CommonUtil.isEmpty(entity.getPPadUrl())){
param.add(PPadUrl.like(entity.getPPadUrl()));
}
if(!CommonUtil.isEmpty(entity.getPBlink())){
param.add(PBlink.like(entity.getPBlink()+"%"));
}
if(!CommonUtil.isEmpty(entity.getPName())){
param.add(PName.eq(entity.getPName()));
}
query.add(param );
List<TsWindowsSoftsProduct> list = getHibernateTemplate().findByCriteria(query) ;
if(!CommonUtil.isEmpty(list)){
return list.get(0);
}
return null;