现在的位置: 首页 > 综合 > 正文

springmvc+hibernate 基础查询

2014年09月15日 ⁄ 综合 ⁄ 共 566字 ⁄ 字号 评论关闭
@Repository
public class ContactPepoleDao extends HibernateBaseDaoImpl<EtlContactPepole, Integer> {
	//返回分页对象,正则条件查询
	public Pagination<Object> getAllContactPepole(Integer start,Integer limit,String name){
		String nameStr = name==null?"":" where name like '%"+name+"%'";
		String rowSql = "from EtlContactPepole"+nameStr;
		String countSql = "select count(contactId) "+rowSql;
		return this.findPageByHQL(rowSql, countSql, start, limit);
	}
        //条件查询
	public EtlContactPepole findContactPepole(Integer contactId){
		String hql = "from EtlContactPepole where contactId="+contactId;
		return (EtlContactPepole)this.findByHQL(hql).get(0);
	}
}

抱歉!评论已关闭.