1.Criteria
Criteria criteria = session.createCriteria(User.class);
criteria.add(Expression.eq("name","liping"));
//criteria.add(Example.create(user));
List userList = criteria.list();
2.HQL
String hql = "from org.hibernate.sample.TUser";
Query query = session.createQuery(hql);
List userList = query.list();
3.SQL
List cats = session.createSQLQuery(
"SELECT {cat.*} FROM CAT {cat} WHERE ROWNUM<10",
"cat",Cat.class).list();
4.GET
User user = session.get("com.jason.User", new Long(69));
...
5.Load
User user = (User) session.load( User.class, new Long(69) );
...
//Session.load(Class theClass, Serializable id) 这个id的类型,对应于theClass中id的类型。
6.Session.find/iterate
List users = session.find("from user");