休眠:ORA-00907:缺少右括号

Hibernate : ORA-00907: missing right parenthesis

我收到此错误:ORA-00907:缺少右括号

使用此 HQL:

select new map(r,count(pt)) from Role r
                    inner join r.portfolioTeams pt
                    inner join pt.teamStatusTransitions ptst
                    inner join ptst.teamStatus tst
                    where pt.id.bankId = :bankId 
                    and pt.id.networkDistributorId = :networkDistributorId 
                    and ptst.id.startDate  <= :startDate 
                    and (ptst.endDate is null or ptst.endDate > :endDate) 
                    and tst.id.teamStatusId in (:statusId) 
                    and (r.id.cpmRoleId in (:roles) OR r.id.cpmRoleId in (:roles1) )

我检查过,没有遗漏括号,我很确定它来自我的计数(pt)。

有什么想法吗?

谢谢

为休眠配置设置 show_sql=true 时,您看到了什么?您是否尝试过 运行 通过替换绑定参数直接在数据库上生成脚本?

有时,如果您没有正确使用引号(例如,在某些情况下您应该使用''而不是'),ORACLE之类的数据库会出现缺少右括号的错误,从而导致语法错误。

在执行查询时可能不是所有的变量(:bankId, :networkDistributorId, :startDate, :endDate, :statusId, :roles, :roles1)都绑定了?

感谢您的回答,

最后我用 keywork "element" 解决了这个问题,然后用 group by

select new map(r as roleKey,count(elements(pt)) as nbTeamKey) from Role r
                inner join r.portfolioTeams pt
                inner join pt.teamStatusTransitions ptst
                inner join ptst.teamStatus tst
                where pt.id.bankId = :bankId 
                and pt.id.networkDistributorId = :networkDistributorId 
                and ptst.id.startDate  <= :startDate 
                and (ptst.endDate is null or ptst.endDate > :endDate) 
                and tst.id.teamStatusId in (:statusId) group by r