-->
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: HQL to get the index of an object in a result list?
PostPosted: Mon Feb 09, 2009 11:18 am 
Newbie

Joined: Thu May 01, 2008 11:52 am
Posts: 17
Using HQL:

    * I know how to get the total number of results for a query.

    * I know how to get a list of Object IDs back for that same query.

Can I use HQL to get the index of a specific Object ID in that list? The only way I know to do this is to get back all of the results from the database, then look through all of the results.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2009 12:16 pm 
Newbie

Joined: Thu May 01, 2008 11:52 am
Posts: 17
Since I am using Oracle as my database, it seems that one way I could solve my question is to:

    1. sort in a subquery
    2. determine which item in the subquery matches the id of 'the object i want to know the sorted index of'.
    3. return the value of the matching magic/psuedo-column rownum


I see that rownum is used 'under the hood' for pagination in Hibernate when using Oracle.

However, I can't seem to configure even a simple query query correctly.

Code:
select dog.rownum from Dog as dog where ...


Any suggestions for how to properly access rownum in my own HQL queries?


Top
 Profile  
 
 Post subject: specify extra-lazy in hql?
PostPosted: Fri Feb 13, 2009 4:11 pm 
Newbie

Joined: Thu May 01, 2008 11:52 am
Posts: 17
It has come to my attention that I might be able to retrieve my query result list as "extra-lazy", and then find out the index of an item in that result list using indexOf().

However, I cannot figure out how to specify that my HQL result list items should be "extra-lazy".

(I do see how an object's collection can be extra-lazy by specifying it in hbm.xml, but I am looking for the ordered items items in my result set to be extra-lazy.)


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.