试图从这里开始这个 SQL:
SELECT DISTINCT iss.ID
FROM Issue AS iss
INNER JOIN Message ON Message.IssueID = iss.ID
INNER JOIN Clinician ON Clinician.UserID = Message.FromUserID
INNER JOIN OrgUnit ON OrgUnit.ID = Clinician.OrgUnitID
WHERE OrgUnit.ID = [id-number]
在 HQL 中:
select distinct iss.id from iss
inner join iss.messages as msg
inner join msg.Sender.OrgUnit as org
where org = :orgUnit
但我不断收到“无法绑定多部分标识符”
映射:
-- 问题 --
<bag name="messages" access="field" inverse="false" lazy="true" cascade="none">
<key column="IssueID" />
<one-to-many class="Message" />
</bag>
-- 临床医生 --
<joined-subclass name="Clinician" table="Clinician" lazy="true">
<key column="UserID" />
<many-to-one name="OrgUnit" column="OrgUnitID" />
</joined-subclass>