这是我的完整SQL,
new BooleanBuilder(
qClaimDataEntity.companyId.eq(companyId)
.or(
qClaimDataEntity.projectDataEntity.remoteProjectDataEntityList
.any().assignedCompanyId.eq(companyId)
)
.or(
qClaimDataEntity.projectDataEntity.remoteProjectDataEntityList
.any().remoteProjectStatus.eq(RemoteProjectStatusEnum.合作中)
)
);
将sql字符串打印为
select
claimdatae0_.*
from
claim_data claimdatae0_
where
claimdatae0_.company_id=?
or exists (
select
1
from
project_data projectdat1_ cross
join
remote_project_data remoteproj2_
where
claimdatae0_.project_data_id=projectdat1_.project_data_id
and projectdat1_.project_data_id=remoteproj2_.project_data_id
and remoteproj2_.assigned_company_id=?
)
or exists (
select
1
from
project_data projectdat3_ cross
join
remote_project_data remoteproj4_
where
claimdatae0_.project_data_id=projectdat3_.project_data_id
and projectdat3_.project_data_id=remoteproj4_.project_data_id
and remoteproj4_.remote_project_status=?
) limit ?
但是我认为可以通过
完成select
claimdatae0_.*
from
claim_data claimdatae0_
where
claimdatae0_.company_id=?
or exists (
select
1
from
project_data projectdat1_ cross
join
remote_project_data remoteproj2_
where
claimdatae0_.project_data_id=projectdat1_.project_data_id
and projectdat1_.project_data_id=remoteproj2_.project_data_id
and remoteproj2_.assigned_company_id=?
and remoteproj2_.remote_project_status=?
) limit ?
最新的Spring数据JPA中不支持SubQuery 和querydsl .any()不支持重复条件 有没有另一种方法可以使用querydsl获取第二个查询?
答案 0 :(得分:0)
该示例是两个单独的or
语句。我认为or
应该嵌套,像这样:
new BooleanBuilder(
qClaimDataEntity.companyId.eq(companyId)
.or(
qClaimDataEntity.projectDataEntity.remoteProjectDataEntityList
.any().assignedCompanyId.eq(companyId)
.or(
qClaimDataEntity.projectDataEntity.remoteProjectDataEntityList
.any().remoteProjectStatus.eq(RemoteProjectStatusEnum.合作中)
)
));