Young9007
2012-10-18 11:33 阅读 248
已采纳

请教一个hibernate的查询问题

表的结构是这样的:

[img]http://dl.iteye.com/upload/attachment/0075/2813/5aced532-0f10-3e47-a054-8b608aa37ab7.png[/img]

现在想把所有featured为1或2的查询出来,1中的结果按照date排序,2中的结果也按date排序,featured=1的所有结果排在2的前面,不管日期如何,这样的HQL语句如何写啊?

先谢~~

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    jinnianshilongnian jinnianshilongnian 2012-10-18 12:20

    select id,featured,date from table where featured in (1, 2) order by featured,date
    再转成hql 即可
    from Model where featured in (1, 2) order by featured,date

    点赞 评论 复制链接分享

相关推荐