case when then else end

public List<Topic> findByForum(Forum forum) {
	return getSession().createQuery(//
	  // TODO 怎么排序
      "FROM Topic t WHERE t.forum=? ORDER BY (CASE t.type WHEN 2 THEN 2 ELSE 0 END) DESC, t.lastUpdateTime DESC")//
	.setParameter(0, forum).list();
}

  

posted @ 2016-06-08 16:45  wujixing909  阅读(134)  评论(0编辑  收藏  举报