JPA子查询无法正常工作

时间:2014-12-05 08:34:42

标签: java sql jpa subquery

我正在尝试执行JPA查询。

select c from Chats c where c.userAndroidId=:userAndroidId and c.companyId = :companyId and c.id >= (select min(c2.id) from Chats c2 where c2.status=1 and c2.companyId = :companyId 
and c2.userAndroidId= :userAndroidId) union all 
(select c3 from chats c3 where c3.userAndroidId=:userAndroidId and c3.companyId = :companyId and c3.id < (select min(c4.id) from Chats c4 where c4.status=1 and c4.companyId = :companyId and c4.userAndroidId=:userAndroidId) order by c3.id desc limit 2) order by c.id desc;

根据我的理解,它有两个变量,userAndroidIdcompanyId

我收到错误

  

并未设置所有已命名参数:[id] [从聊天c中选择c   其中c.userAndroidId =:userAndroidId和c.companyId =:companyId   和id&gt; :id desc的id顺序]

0 个答案:

没有答案