A B C三个类
A与B是一对多
B与C是一对一现在的查询条件是知道C的id,要找到对应的所有A,这样的HQL怎么写啊

解决方案 »

  1.   

    from B.A WHERE B.C.ID=id group by B.A.ID
      

  2.   

    select * from A a,B b,C c where a.id = b.id and b.id = c.id and c.id="你要查询的C的id"
      

  3.   

    是a的list,并且用group by把重复的a给去掉了
    或者你from distinct B.A  WHERE B.C.ID=i看看加distinct有用吗?
      

  4.   


    看清楚3楼的意思了
    把后面group by去掉
    from  B.A  WHERE B.C.ID