Posted on 2009-08-16 11:14
Robert Su 阅读(650)
评论(0) 编辑 收藏 所属分类:
工程相关
public List findByInstance(IInsInfo instance) {
log.debug("finding IInsInfo instances with given IInsInfo instance");
try {
Criteria crit = getSession().createCriteria(instance.getClass());
Criterion iname = null, gdfield = null, kind = null, property = null;
Conjunction conjunction = Restrictions.conjunction();// 合取
//
if (instance.getIname() != null)
if (!instance.getIname().equals(null)) {
iname = Restrictions.like("iname", "%"
+ instance.getIname() + "%");
conjunction.add(iname);
}
if (instance.getGdfield() != null)
if (!instance.getGdfield().equals("")) {
gdfield = Restrictions.eq("gdfield", instance.getGdfield());
conjunction.add(gdfield);
}
if (instance.getKind() != null)
if (!instance.getKind().equals("")) {
kind = Restrictions.eq("kind", instance.getKind());
conjunction.add(kind);
}
if (instance.getProperty() != null)
if (!instance.getProperty().equals("")) {
property = Restrictions.eq("property", instance
.getProperty());
conjunction.add(property);
}
crit.add(conjunction);
return crit.list();
} catch (RuntimeException re) {
log.error("find by IInsInfo instance failed", re);
throw re;
}
}