Hi,
I have 3 tables:
Tasks:
taskid int PK
jobid int FK
description String
Jobs:
jobid PK
clientid int FK
Clients:
clientid PK
clientname String.
How can I get the Clients:clientname via the Jobs table starting from a
taskid? I know how to do it with 1 level on "indirection" but I don't
know how to chain 2 queries...
taskid -> jobid -> clientid -> clientname.
I think it should be something like that:
<result-map name="result" class="com.jobtracking.Task">
<property name="taskId" column="taskid"/>
<property name="taskNotes" column="notes"/>
<property name="taskJobId" column="jobid"/>
<property name="clientName" column="jobid"
mapped-statement="getClientNameByJobId"/>
</result-map>
<mapped-statement name="getTaskList" result-map="result">
select taskid,notes,assignedid,deptid,completion,duedate,
donedate,tasktypeid,startdate,jobid
from tasks order by duedate
</mapped-statement>
<result-map name="clientNameResult" class="com.jobtracking.Job">
<property name="clientId" column="clientid"/>
<property name="clientName" column="clientid"
mapped-statement="getClientNameById"/>
</result-map>
<mapped-statement name="getClientNameByJobId"
result-map="clientNameResult">
select clientid from jobs where jobid=#value#
</mapped-statement>
<mapped-statement name="getClientNameById"
result-class="java.lang.String">
select name from clients where clientid = #value#
</mapped-statement>
Thanks
Fred
begin:vcard
fn:fjanon
n:Janon;Fred
email;internet:[EMAIL PROTECTED]
title:Sr S/W Engineer & Architect
x-mozilla-html:TRUE
url:http://www.geocities.com/fjanon
version:2.1
end:vcard