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)"