-->
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.  [ 2 posts ] 
Author Message
 Post subject: <list> - does a DB versus in-memory ordering happen?
PostPosted: Sun Sep 10, 2006 1:23 am 
Newbie

Joined: Tue Aug 16, 2005 8:28 am
Posts: 15
Mapping:

One-Many Side:
<list name="prefferedCommModes" cascade="all-delete-orphan" lazy="true">
<key column="CUSTOMER_ID" not-null="true" />
<list-index column="PRIORITY"/>
<one-to-many class="CustomerPreferredCommunicationMode" />
</list>


Many-One Side:
<many-to-one name="client" column="CUSTOMER_ID" not-null="true"
insert="false" update="false" />

When i traverse the association, i.e. client.getPreferredCommunicationModes() here is my observation:

The SQL fired on fetching the List is of this nature:

Hibernate: select prefferedc0_.CUSTOMER_ID as CUSTOMER4_1_, prefferedc0_.CUSTOMER_PREF_COMMN_MODE_ID as CUSTOMER1_1_, prefferedc0_.PRIORITY as PRIORITY1_, prefferedc0_.CUSTOMER_PREF_COMMN_MODE_ID as CUSTOMER1_110_0_, prefferedc0_.COMMUNICATION_MODE_CD as COMMUNIC2_110_0_, prefferedc0_.PRIORITY as PRIORITY110_0_, prefferedc0_.CUSTOMER_ID as CUSTOMER4_110_0_ from WW_CUSTOMER_PREF_COMMN_MODE prefferedc0_ where prefferedc0_.CUSTOMER_ID=?

It seems that the ORDER BY PRIORITY does not happen in the database. So most likely it's an in-memory Sort that's happening.

My question is: Using <list> is there anyway to have the DB SQL Order by happen? Something like:


from WW_CUSTOMER_PREF_COMMN_MODE prefferedc0_
where prefferedc0_.CUSTOMER_ID=?
ORDER BY PRIORITY ASC

_________________
Give Credit Where Due (if I answer your post)


Top
 Profile  
 
 Post subject: answering my own question.
PostPosted: Sun Sep 10, 2006 2:32 am 
Newbie

Joined: Tue Aug 16, 2005 8:28 am
Posts: 15
actually i think i can answer my own question. hibernate may not need to really "sort" or order-by

all it would need to do is:

list.add(priority, element)

where priority would come from the DB column

_________________
Give Credit Where Due (if I answer your post)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.