我正在构建JOOQ查询的WHERE子句。有些条件使用EXISTS,我想将子查询提供为纯SQL,因为它们是用JOOQ表示的。例如。
select 1 from jsonb_array_elements(resource->'name') as t1,
jsonb_array_elements_text(t1.value->'given') as t2
where t2.value like ?
但是DSL.exists()仅接受Select类型作为参数,无论我使用哪种DSL.select ...()方法,它都会用另一个select包装我的SQL代码段。
DSL.exists(DSL.selectFrom(DSL.sql(...)))
查询将是这样的:
... where exists (select * from (select 1 from ...
有没有办法避免不必要的包装器选择?
您可以使用像这样的普通SQL条件:
Condition condition = DSL.condition("exists (<your select here>)");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句