hql中怎么使用top函数?一直报错 怎么优化啊 求大神帮忙
问题描述:
hql语句如下:
String hql = " from Contract c left join fetch c.family cf left join fetch c.house ch left join fetch ch.building chb left join fetch chb.project chbp " +
"where (c.id in (SELECT id from Contract a where a.id in (SELECT TOP 1 id from Contract b where status=0 and a.familyId=b.familyId order BY startDate Desc)) or c.addType = 2)"
答
hql 有类似oracle的rownum,可以了解一下