select * from (select * from t_P p where p.projectStatus =2)t1 where t1.projectId not in ( select b.projectId from t_Bb where b.bidderId =2)这个SQL在oracle里肯定没问题,但是转成HQL就不行,请问该怎么写?

解决方案 »

  1.   

    没写过,帮你顶下!不过hibernate可以用原生的SQL
      

  2.   

    建议用Criteria来查询!用hlq比较难写!
      

  3.   

    建议自己写一个sql语句 如过用hql的话 要嵌套
      

  4.   

    实体嵌套比较麻烦,内存占用多,建议使用NativeSQL。如果真要写HQL。from 实体类 inner join 实体类关联主键 inner join 实体类关联主键 =NULL(对应Not IN)你也可以这样写:select {别名.*} from 主表 别名 inner join A on(主键关联序列) inner join B on(主键关联序列) where 条件序列 and XXXB.XXX IS NULL对别名 填充实体。