-->
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: Help mapping a parent to the most current child only
PostPosted: Fri Aug 22, 2008 5:17 pm 
Newbie

Joined: Fri Aug 22, 2008 4:56 pm
Posts: 1
Here is the case:
I know how to map all the children in the parent class using a list or set. But this one has a twist: I want to get only the child matches the last version number in the parent class.

Parent class:
<hibernate-mapping package="com.company.hibernate">
<class mutable="true" name="com.company.hibernate.Node" table="NODE">
<id name="id" column="UUID" type="UuidType">
</id>
<property name="lastVersionNumber" column="LAST_VERSION_NUMBER" not-null="false" type="int">
</property>
<property name="category" column="CATEGORY" not-null="true" type="string">
</property>
<property name="name" column="NAME" not-null="true" type="string">
</property>
?? how to map to get the content object that matches the lastVersionNumber in this class??
</class>
</hibernate-mapping>

Child class:
<hibernate-mapping package="com.company.hibernate">
<class mutable="true" name="com.company.hibernate.Content" table="CONTENT">
<composite-id class="com.company.hibernate.ContentKey" name="key">
<key-property name="id" column="UUID" type="UuidType">
</key-property>
<key-property name="version" column="VERSION" type="int">
</key-property>
</composite-id>
<property name="text" column="TEXT" not-null="false" type="string">
</property>
<many-to-one name="node" class="com.company.hibernate.Node"
lazy="false" insert="false" update="false">
<column name="UUID"/>
</many-to-one>
</class>
</hibernate-mapping>


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.