-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: how to map max() value as attribute
PostPosted: Wed Nov 21, 2007 5:27 am 
Newbie

Joined: Wed Oct 10, 2007 2:25 am
Posts: 2
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:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.