views:

142

answers:

1

Trying to go from here this 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]

To here in HQL:

select distinct iss.id from iss
inner join iss.messages as msg
inner join msg.Sender.OrgUnit as org
where org = :orgUnit

But I keep getting "multipart identifier could not be bound"

Mappings:
-- Issue --

<bag name="messages" access="field" inverse="false" lazy="true" cascade="none">
  <key column="IssueID" />
  <one-to-many class="Message" />
</bag>

-- Clinician --

<joined-subclass name="Clinician" table="Clinician" lazy="true">
  <key column="UserID" />
  <many-to-one name="OrgUnit" column="OrgUnitID" />
</joined-subclass>

A: 

Just figured out that the easiest answer to this problem is to avoid it. It does work in SQL, so why not just do it in SQL.

Reverend Sfinks