0
試圖從這裏這個SQL去:轉換從SQL到HQL失敗
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>
如果沒有映射,無法幫助您使用HQL。 – 2009-08-21 08:57:56
我可能應該提到患者和臨牀醫師都是從用戶身上繼承的。病人沒有OrgUnit道具。 – 2009-08-21 10:26:40