这样写
from Menu a where a.parent is null and (a.permission is null or a.permission in (
select distinct b from Permission b left join b.users d where d.id = ? ,
select distinct h from Permission h left join h.depts f where f.id = ? )
)
报这个错
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: , near line 1, column 195 [from com.luoxudong.entity.Menu a where a.parent is null and (a.permission is null or a.permission in (select distinct b from com.luoxudong.entity.Permission b left join b.users d where d.id = ? ,select distinct h from com.luoxudong.entity.Permission h left join h.depts f where f.id = ? ))]这样写
from Menu a where a.parent is null and (a.permission is null or a.permission in (
(select distinct b from Permission b left join b.users d where d.id = ? ),
(select distinct h from Permission h left join h.depts f where f.id = ?)
 )
)
报这个错
Caused by: org.hibernate.HibernateException: ordinal parameter mismatch到底该怎么写

解决方案 »

  1.   

    from Menu a where a.parent is null and (a.permission is null or a.permission in (
    select distinct b from Permission b left join b.users d on d.id = ?  left join h.depts f on f.id = ? )
    )
      

  2.   

    jianglang 两个left join是并集还是交集啊,我晕
      

  3.   

    对了,我忘了说了,数据库是Oracle数据库
      

  4.   

    from Menu a where a.parent is null and (a.permission is null or a.permission in (
    select distinct b from Permission b left join b.users d on d.id = ? ,
    select distinct h from Permission h left join h.depts f on f.id = ? )
    )
      

  5.   

    jianglang 你那不是和我写的一样么
      

  6.   

    a.permission 那别用对象比用他里面的属性这样肯定行
      

  7.   

    如果hql解决不了问题,你可以考虑用createSqlQuery创建native sql,这样就很简单的知道 sql问题所在
      

  8.   

    问题解决了,用下面这条hql就行,至于为什么我就不知道,如果哪位大侠知道的,教教小弟,谢谢大家
    from Menu a where a.parent is null and (a.permission is null or a.permission in (
    select distinct b from Permission b left join b.users d where d.id = ?) or
    a.permission in (select distinct h from Permission h left join h.depts f where f.id = ? ))