在我的JPA模型中有3个表A,B,C。
我的查询是:
SELECT a FROM A a
WHERE EXISTS (
SELECT c from C c LEFT JOIN B b"
ON c = b.c AND b.a = a
WHERE c.date BETWEEN CURRENT_TIMESTAMP AND :pUntil AND b.a IS NULL
)
背景是我希望A中所有没有b的条目的实体在将来链接到事件C。
问题是我得到Column 'T0.ID' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or ...
修改
:将其视为A是用户表,C是事件,B存储事件用户的注册。我希望获得所有用户,这些用户在参数pUntil
之前尚未注册所有未来事件。
答案 0 :(得分:1)
虽然我同意Neil,但我通过更改查询来解决此问题。这是新查询:
SELECT a FROM A a
WHERE EXISTS (
SELECT c from C c
WHERE c.date BETWEEN CURRENT_TIMESTAMP AND :pUntil
AND NOT EXISTS (
SELECT b from B b
WHERE b.c= c and b.a = a
)
)