-->
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: Projection over Projection - How can I do?
PostPosted: Tue Nov 04, 2008 1:38 pm 
Newbie

Joined: Thu Jul 24, 2008 10:13 am
Posts: 17
Hello! I'm trying to emulate this query using Criteria and Projections, but I can't do it:

Code:
   SELECT rese_pos_id
   FROM (SELECT DISTINCT rese_pos_id, rese_pos_ord
             FROM researcher_position
             ORDER BY rese_pos_ord) idsOrd;


I achieved to build the "subquery" :

Code:
return (Collection<Integer>) getSession().createCriteria(ResearcherPosition.class)
         .setProjection(Projections.distinct(
               Projections.projectionList()
                        .add(Projections.property("researcherPositionPK.positionID"))
                        .add(Projections.property("order"))))   
         .addOrder(Order.asc("order"))
         .list();


but I don't know the way to "project" the final result over the column "rese_pos_id". I need the other column (rese_pos_ord) to order the elements into the column rese_pos_id, so it's neccesary to put it into the SELECT. The "subquery" works alone, retrieving this data:

Code:
rese_pos_id  |  rese_pos_ord
----------------------------------
5            |            1
6            |            2
1            |            3

but, how can I project in the final result only the column rese_pos_id ? I was thinking about a DetachedCriteria, but I don't know how to build a Criteria about the result of the detached one.

Thanks


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.