hibernate的条件查询

static List query(String name){

    Session session = null;

   

     try{

 

         s = HibernateUtil.getSession();

         Criteria c = session.createCriteria(User.class);
         c.add(Restrictions.eq("name", name));//约束条件
         c.setFirstResult(0);//分页
         c.setMaxResults(10);//分页
  
         User user = (User) c.uniqueResult();
  
         List list = c.list();

     }finally{

             if(s!=null)

             s.close();

     }

 

     return list

}

你可能感兴趣的:(C++,c,Hibernate,C#)