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.  [ 3 posts ] 
Author Message
 Post subject: order-by for a lazy one-to-many mapping - is it possible ?
PostPosted: Mon Feb 14, 2005 4:41 am 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
Hibernate version: 2.1.6

Sorry if someone posted before.

I have a lazy one-to-many association and want to get sorted items:
<set items table="JOIN_TABLE" cascade="save-update" inverse="false"
lazy="true" order-by="??????">
<key column="ITEM_ID"/>
<one-to-many class name="..."/>
</set>

How do I specify the order-by ? It seems that the I can only use a column in the JOIN_TABLE but what I want is to sort the items based on a column in the ITEMS table.

any solution ?

thanks
li xin


Top
 Profile  
 
 Post subject: Re: order-by for a lazy one-to-many mapping - is it possible
PostPosted: Mon Feb 14, 2005 9:47 am 
Regular
Regular

Joined: Thu Dec 18, 2003 2:14 am
Posts: 103
Location: Brooklyn, NY
Have you tried? Seems like this is the expected behavior. if it is not working, please post more information about your mappings.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 8:42 am 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
Here is the mapping file - A has one-to-many association with B:

A
===
<hibernate-mapping>
<class name="A" table="A">
<id name="aId" type="long" column="A_ID" unsaved-value="0">
<generator class="identity"/>
</id>

<property name="aName" type="string" not-null="true" column="NAME"/>
<set name="bs" table="A_B" cascade="save-update" inverse="false" lazy="true">
<key column="A_ID"/>
<one-to-many class="B"/>
</set>

</class>
</hibernate-mapping>


B
===

<hibernate-mapping>

<class name="B" table="B">
<id name="bId" type="long" column="B_ID" unsaved-value="0">
<generator class="identity"/>
</id>

<property name="bName" type="string" not-null="true" column="NAME"/>

<property name="sequence" type="integer" column="SEQUENCE"/>

</class>
</hibernate-mapping>

So what I would like is to have the 'order-by' in class A, sort the bs according to the column SEQUENCE in class b.

is it possible ?

thanks
li xin


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

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.