Hello
I am trying to use a named sql query that is a table join. How do I do this? Do I need a mapping for each of the tables used in the query? Ideally, I'd just like to have a java class that holds the 4 columns that are returned. I read the docs on this topic, but there aren't enough examples. I don't know what classes I need. I don't know what an "alias" is. I just want to run this SQL statement, and the results in a object. Thanks in advance!
My named sql-query:
<sql-query name="maxWeekPerForm">
<return alias="fw" class="FormAndWindow"/>
<![CDATA[
select A.study, E.fname, D.winunt, D.winval
from table1 A
join table2 B on A.id = B.id
join table3 C on C.id = B.id
join table4 D on D.id = C.id
join table5 E on E.id = E.id
where D.winval in
(
select max(winval)
from table4 F
where F.id = D.id
)
group by A.study, E.fname, D.winunt, D.winval
order by A.study, E.fname, D.winunt, D.winval
]]>
</sql-query>
|