目前只能做到按照主题的发表时间来降序排序,让最后发表的主题显示在第一行。 //根据分页获取主题列表
@SuppressWarnings("unchecked")
public List<Topic> getTopicByPage(int boardId,int pages)
{
String hql="from Topic as t where t.board.id="+boardId+"order by t.publishTime desc";
Session session=this.getSession();
Query query=session.createQuery(hql);
query.setFirstResult(20*pages);
query.setMaxResults(20);
List<Topic> topics=query.list();
session.close();
return topics;
}
现在想让主题列表按照最后回复时间排序,没有思路了,有没有高人能提供思路解决这一问题,先谢谢了。
@SuppressWarnings("unchecked")
public List<Topic> getTopicByPage(int boardId,int pages)
{
String hql="from Topic as t where t.board.id="+boardId+"order by t.publishTime desc";
Session session=this.getSession();
Query query=session.createQuery(hql);
query.setFirstResult(20*pages);
query.setMaxResults(20);
List<Topic> topics=query.list();
session.close();
return topics;
}
现在想让主题列表按照最后回复时间排序,没有思路了,有没有高人能提供思路解决这一问题,先谢谢了。
数据库里再增加一个state 字段,set类型。
给帖子加一个level字段,一般的帖子一个等级,置顶的一个等级,然后同等级的帖子再按updatetime字段排序