在HQL中排序可以使用order by排序查询结果,asc是升序;desc是降序

如:

 Query query = session.createQuery("from Guestbook where name like'XXX' asc");

 Query query = session.createQuery("from Guestbook order by name ,id asc");