如何使用JPA运行如下所示的查询. (它适用于纯sql)
SELECT t FROM table t WHERE ( CASE WHEN (( ... subquery ... ) IS NULL) THEN (t.category IS NULL) ELSE (t.viewId = :viewId) END )
我在IS遇到MismatchedTokenException
那么(t.category IS NULL)
可能吗?或者我需要重写这个查询?
解决方法
您可以将where子句转换为:
where ((... my first condition ...) and (something is NULL)) or (not (... first condition ...) and (something2 = otherthing))