Hello!
I need to map max() value as attribute.
I found example in hibernate reference:
Code:
<join>
<key column="employeeId"/>
<subselect>
select employeeId, orgId
from Employments
group by orgId
having startDate = max(startDate)
</subselect>
<many-to-one name="mostRecentEmployer"
class="Organization"
column="orgId"/>
</join>
I'm trying to implement it to my mapping file:
Code:
<class name="model.User" table="CUSER">
<id name="id" type="long" column="ID">
<generator class="increment" />
</id>
<join table="USER_STAGE">
<key column="USER_ID" />
<subselect>
SELECT USER_ID, STAGE_ID
FROM USER_STAGE
GROUP BY STAGE_ID
HAVING DATED = max(DATED)
</subselect>
<many-to-one name="currentStage" class="model.Stage"
column="STAGE_ID" />
</join>
<property name="extId" column="EXT_ID" type="string"
length="20" />
<property name="sFirstname" column="S_FIRSTNAME" type="string"
length="50" />
</class>
Is it right code?
Eclipse marks red lines with <join>, like it doesn't fit DTD.
Any help will be very appreciated.
Thank you in advance.
Hibernate version: 3.2
Code: