问题
the following query :
SELECT P FROM Project P WHERE :currentUser IN(P.assignedUsers)
throws the following error :
org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement: "...."; expected "NOT, EXISTS, INTERSECTS, SELECT, FROM";
Am i using the IN operator wrong, or am i supposed to do it differently.
Project.assignedUsers : is a list containing users (a OneToMany Relationship). and the currentUser parameter is a valid user.
回答1:
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
来源:https://stackoverflow.com/questions/32631930/issue-when-trying-to-use-the-in-operator-in-a-jpql-query