I ran into some problems.
I want to write a subquery according to SQL using querydsl.
SQL (ps: v_task_recipient is a view.)
select v.title, v.create_date_time from v_task_recipient v
where
(select r.branch_id from tbl_recipient r where v.recipient_id = r.id)
in
(2704230,2703041,2702932);
in the java part, I write like this:
List<Branch> branches = user.getBranchesForPermissionOperation(Operations.claim_update);
ListSubQuery<Branch> subquery = new JPASubQuery().from(branchRecipient).where(taskRecipentView.recipient_id.eq(branchRecipient.id)).list(branchRecipient.branch);
for(Branch branch: branches)
{
ex = ex == null ? subquery.contains(branch) : ex.or(subquery.contains(branch));
}
is there a better solution to avoid an ugly cycle? can i use some kind of expression like 'in'?
and the hardest part is branchRecipient is inherited from the parent recipient.
private static QRecipient recipient = QRecipient.recipient;
private static QBranchRecipient branchRecipient = recipient.as(QBranchRecipient.class);
private static QUserRecipient userRecipient = recipient.as(QUserRecipient.class);
it always raises an exception
java.lang.IllegalArgumentException: Unhandled destination path. Add this path as the request source to be able to reference it.
source
share