日期:2014-05-18  浏览次数:20755 次

请教hibernate高手一个 HQL查询方法
一个THouse表   里面对应字段有   id     name(房屋名字)   houseType(房屋类型)  
现在我要查询的是每种房屋类型列出三条记录来
用sql语句实现就是下面这个情况


select   t   from   THouse   as   t   where   t.id   in  
(select   top   3   a.id   from   THous   as   a   where   t.houseType=a.houseType)

------解决方案--------------------
you can use the native sql function of hibernate.