@SuppressWarnings("unchecked")
public List<FactoryBean> searchFactoryListByPaging(final int start,
final int limit, final FactoryBean factoryBean) {
return (List<FactoryBean>) getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Criteria criteria = session
.createCriteria(FactoryBean.class);
// 條件
if (null != factoryBean) {
if (null != factoryBean.getFullName()
&& !"".equals(factoryBean.getFullName())) {
criteria.add(Restrictions.like("fullName",
factoryBean.getFullName(),
MatchMode.ANYWHERE));
criteria.add(Restrictions.like("simpleName",
factoryBean.getFullName(),
MatchMode.ANYWHERE));
criteria.add(Restrictions.like("unifyName",
factoryBean.getFullName(),
MatchMode.ANYWHERE));
}
if (null != factoryBean.getChargeMan()
&& !"".equals(factoryBean.getChargeMan())) {
criteria.add(Restrictions.like("chargeMan",
factoryBean.getChargeMan(),
MatchMode.ANYWHERE));
}
if (null != factoryBean.getContactMan()
&& !"".equals(factoryBean.getContactMan())) {
criteria.add(Restrictions.like("contactMan",
factoryBean.getContactMan(),
MatchMode.ANYWHERE));
}
if (null != factoryBean.getEmail()
&& !"".equals(factoryBean.getEmail())) {
criteria.add(Restrictions.like("email",
factoryBean.getEmail(),
MatchMode.ANYWHERE));
}
if (null != factoryBean.getFactoryAdderss()
&& !"".equals(factoryBean
.getFactoryAdderss())) {
criteria.add(Restrictions.like(
"factoryAdderss", factoryBean
.getFactoryAdderss(),
MatchMode.ANYWHERE));
}
if (null != factoryBean.getRemark()
&& !"".equals(factoryBean.getRemark())) {
criteria.add(Restrictions.like("remark",
factoryBean.getRemark(),
MatchMode.ANYWHERE));
}
if (null != factoryBean.getBizFactorytype()) {
criteria.add(Restrictions.eq("bizFactorytype",
factoryBean.getBizFactorytype()));
}
}
criteria.add(Restrictions.in("status",
new Integer[] { 1 }));
criteria.addOrder(Order.desc("factoryId"));
criteria.setFirstResult(start).setMaxResults(limit);
return criteria.list();
}
});
}