SQL如下:
select * from Orders o,(select city,addressee,zipcode,[address] from Orders 
group by city,addressee,zipcode,[address] having count(*) > 1) t
where o.city = t.city and o.addressee = t.addressee and o.zipcode = t.zipcode and o.[address] = t.[address]像这种select a,b where a.XX = b.XX 的语法可不可以转成HQL?或者有没有别的替代写法?

解决方案 »

  1.   

    上面说错了,补充一下:
    像这种select a,(select * from b) c where a.XX = c.XX 的语法可不可以转成HQL?或者有没有别的替代写法?
      

  2.   

    select a,(select * from b) c where a.XX = c.XX 你可以这样写啊
    from a where a.xx in (select b.xx from b)
      

  3.   

    但不只一项,那估计我得这样写了:
    from a where a.xx in (select b.City from b) and a.xx in (select b.xx from b) and a.xx in (select b.xx from b) and a.xx in (select b.xx from b) and a.xx in (select b.xx from b)....
      

  4.   

    Ok.solution:
    “select a,(select * from b) c where a.XX = c.XX”。在hibernate中表对应的是类,那么在a表对应的这个类中,应该有一个集合List b = new ArrayList();下面你应该知道我干什么了吧:
    运用一对多的关系啊:From A,B where A.xx = B.xx;但是你要在配置文件中配置一对多的关系。这样应该是可以的,我晚上回家测试一下,思路应该没什么问题的。