-->
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: Using a propety from a one-to-one mapping within an orderBy
PostPosted: Wed Jan 07, 2009 5:04 pm 
Newbie

Joined: Wed Jan 07, 2009 4:55 pm
Posts: 2
I have the following classes mapped and I would like to be able to use the sortOrder property of the CorpWebLink class (which is a one-to-one mapping of the within the CorpSalesRepWebLink class) as an order-by of the corpSalesRepWebLinks set. Is this possible?

CorpSalesRepWeb
<class name="CorpSalesRepWeb" table="CORP_SALES_REP_WEB">
<id name="salesRepNumber" column="SALES_REP_NBR" type="integer">
<generator class="native" />
</id>

<property name="webName1" column="WEB_NAME1" type="string" />
<property name="webName2" column="WEB_NAME2" type="string" />

<set name="corpSalesRepWebLinks" cascade="all" inverse="true" lazy="false">
<key column="SALES_REP_NBR" />
<one-to-many class="CorpSalesRepWebLink" />
</set>

</class>

CorpSalesRepWebLink
<class name="CorpSalesRepWebLink" table="CORP_SALES_REP_WEB_LINKS">
<id name="webLinkId" column="WEB_LINK_ID" type="integer">
<generator class="native" />
</id>
<property name="salesRepNumber" column="SALES_REP_NBR" type="integer" />
<one-to-one name="corpWebLink" class="CorpWebLink" lazy="false"/>

</class>

CorpWebLink
<class name="CorpWebLink" table="CORP_WEB_LINKS">
<id name="webLinkId" column="WEB_LINK_ID" type="integer">
<generator class="native" />
</id>
<property name="linkType" column="LINK_TYPE" type="string" />
<property name="linkName" column="LINK_NAME" type="string" />
<property name="divisionCode" column="DIVISION_CODE" type="string" />
<property name="linkURL" column="LINK_URL" type="string" />
<property name="sortOrder" column="SORT_ORDER" type="integer" />
<property name="imageName" column="IMAGE_NAME" type="string" />
<one-to-one name="corpSalesRepWebLink" class="CorpSalesRepWebLink" lazy="false"/>
<one-to-one name="corpWebLinkType" class="CorpWebLinkType" lazy="false"/>

</class>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2009 10:08 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
I don't think it's possible, since the orderBy clause is injected into the sql-statement. So if you wanted to order by CorpWebLink.sortOrder you needed to know the alias CorpWebLink's table gets in every statement.

Alternatively you could order the collection in CorpSalesRepWeb's setCorpSalesRepWebLinks(...) method.


Top
 Profile  
 
 Post subject: Using a propety from a one-to-one mapping within an orderBy
PostPosted: Thu Jan 08, 2009 10:20 am 
Newbie

Joined: Wed Jan 07, 2009 4:55 pm
Posts: 2
I was able to get this working by mapping the sortOrder property of the CorpWebLink class to the CorpSalesRepWebLink class by using a property with a formula. Then I was able to use that property to sort the collection.


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.