use _rv in sub-query for partner in DebitorEntity

This commit is contained in:
Michael Hoennig 2024-03-23 11:41:59 +01:00
parent acd1bd9e51
commit 36d96b543a

View File

@ -55,14 +55,13 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
@ManyToOne
@JoinFormula(
referencedColumnName = "uuid",
// FIXME: use _rv in sub-query
value = """
(
SELECT DISTINCT partner.uuid
FROM hs_office_partner partner
JOIN hs_office_relation dRel
FROM hs_office_partner_rv partner
JOIN hs_office_relation_rv dRel
ON dRel.uuid = debitorreluuid AND dRel.type = 'DEBITOR'
JOIN hs_office_relation pRel
JOIN hs_office_relation_rv pRel
ON pRel.uuid = partner.partnerRelUuid AND pRel.type = 'PARTNER'
WHERE pRel.holderUuid = dRel.anchorUuid
)