尝试在JPQL查询中使用IN运算符时出现问题 [英] Issue when trying to use the IN operator in a JPQL query

查看:384
本文介绍了尝试在JPQL查询中使用IN运算符时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下查询:

SELECT P FROM Project P WHERE :currentUser IN(P.assignedUsers)

引发以下错误:

org.h2.jdbc.JdbcSQLException:SQL语句中的语法错误:"...."; 预期为"NOT,EXISTS,INTERSECTS,SELECT,FROM";

org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement: "...."; expected "NOT, EXISTS, INTERSECTS, SELECT, FROM";

我使用IN运算符是错误的还是应该做不同的事情?

Am i using the IN operator wrong, or am i supposed to do it differently.

Project.assignedUsers:是一个包含用户的列表(一对多关系). 并且currentUser参数是有效用户.

Project.assignedUsers : is a list containing users (a OneToMany Relationship). and the currentUser parameter is a valid user.

推荐答案

您不能为此目的使用隐式联接.您可能想利用 member of 运算符:

You cannot use implicit joins for this purpose; you probably want to utilize the member of operator:

SELECT P FROM Project P WHERE :currentUser MEMBER OF P.assignedUsers

这篇关于尝试在JPQL查询中使用IN运算符时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆