我需要从电话号码列表中选择项目,这些电话号码对于某些电话号码可以具有空值。我目前使用的BooleanBuilder子句是:
clause.and(QDashboard.dashboard.phoneList.any().number.isNull().
or(QDashboard.dashboard.phoneList.any().number.in(numbers)));
以及为上述子句生成的SQL查询是:
AND ( EXISTS
(SELECT 1
FROM phone_list pl
WHERE parent.id =pl.recordid
AND ( pl.number IS NULL )
)
OR EXISTS
(SELECT 1
FROM phone_list p2
WHERE parent.id =p2.recordid
AND ( p2.number IN ( ?, ?, ?, ?, ?, ?, ? ) )
)
我注意到这个查询对于大型数据集来说速度较慢,如果SQL是这样的话会更快:
AND ( EXISTS
(SELECT 1
FROM phone_list pl
WHERE parent.id =pl.recordid
AND ( pl.number IN ( ?, ?, ?, ?, ?, ?, ? )
OR pl.number IS NULL)
));
如何修改BooleanBuilder子句以上述格式生成SQL查询?