-->
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: Performing complex sorting/ordering in HQL/SQL/Criteria
PostPosted: Thu Apr 19, 2007 4:00 pm 
Newbie

Joined: Tue Mar 15, 2005 11:13 am
Posts: 2
I'm trying to implement pagination in several of my DAO classes. Up to somewhat recently simply fetching *ALL* results has been sufficient, but we're starting to see performance issues and are looking to implement pagination. The problem is that when we fetched *ALL* results, we could then perform very complex sorting. Now that we're only going to be receiving a portion of the overall results, performing sorting in this way is no longer an option - it *has* to be done as part of the query.

From my research one interesting option I saw was to create mappings for formula-calculated properties in my domain objects. For example, I could do something like:

...
<property name="complexProperty" type="string">
<property name="complexPropertySortValue" type="integer">
<formula>
case
when complexProperty is null then 0
when complexProperty is ... then 1
when complexProperty is ... then 2
else 0
end
</formula>
</property>
...

and then the order by clause in the appropriate query is pretty simple. In our case that will help in many, but not all of our situations. What other options do I have to perform complex sorting?


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.