public MyUser getByProperty(String uid,String pwd) {
DetachedCriteria criteria=DetachedCriteria.forClass(MyUser.class);
criteria.add(Restrictions.eq("uid",uid));
criteria.add(Restrictions.eq("pwd",pwd));
List<MyUser> list= hbt.findByCriteria(criteria);
DetachedCriteria criteria=DetachedCriteria.forClass(MyUser.class);
criteria.add(Restrictions.eq("uid",uid));
criteria.add(Restrictions.eq("pwd",pwd));
List<MyUser> list= hbt.findByCriteria(criteria);
}
标准步骤
1 创建标准 criteria --- DetachedCriteria criteria=DetachedCriteria.forClass(MyUser.class);
2 为标准添加限制(restrictions)--criteria.add(Restrictions.eq("uid",uid));
3调用hibernamteTemplate 的findByCriteria(criteria)方法