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)
|