查询结果排序

QBC方式
Query q=session.createQuery(“from Customer c order by c.name”);
Criteria c=session.createCriteria(Customer.class);
c.addOrder(Order.asc(“name”));
c.addOrder(Order.desc(“name”));//这里可以填原名,别名,列数
List result=c.list();


HQL方式只能像写SQL一样,在句子里写 order by 如:
Query query = session.createQuery("from Customer c order by c.name asc,c.age desc");

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