如何使用JPA运行如下查询。 (它适用于普通SQL)
SELECT t
FROM table t
WHERE
(
CASE WHEN (( ... subquery ... ) IS NULL)
THEN (t.category IS NULL)
ELSE (t.viewId = :viewId)
END
)
我在
MismatchedTokenException
上获得了IS
THEN (t.category IS NULL)
是否可以?还是需要我重写此查询?
最佳答案
您可以将where子句转换为:
where
((... my first condition ...) and (something is NULL))
or
(not (... first condition ...) and (something2 = otherthing))