一般写法:
select * from itcast_topic order by (case type when 2 then 2 else 1 end ) desc ,postTime desc
hql写法类似:
public List<Topic> findTopicByForum(Forum model) {
String hql = "FROM Topic t WHERE t.forum = ? ORDER BY (CASE t.type WHEN 2 THEN 2 ELSE 1 END) DESC,t.postTime DESC";
Query query = this.getSession().createQuery(hql);
query.setParameter(0, model);
return query.list();
}