-->
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: order by and row count in criteria query
PostPosted: Wed Feb 14, 2007 1:31 am 
Beginner
Beginner

Joined: Tue Dec 20, 2005 9:40 pm
Posts: 20
Currently I have a method with:

Code:
ISession session = _sessionManager.OpenSession();
ISession innerSession = ((SessionDelegate)session).InnerSession;
queryObject.SetProjection(Projections.RowCount());
ICriteria criteria = queryObject.GetExecutableCriteria(innerSession);
criteria.SetFirstResult(0);
int rowCount = (int)criteria.UniqueResult();
queryObject.SetProjection(null);
queryObject.SetResultTransformer(CriteriaUtil.RootEntity);
return rowCount;


The problem is if I have an order by in my criteria query, I get the error the property isn't contained in an aggregate.

Is there any way to strip the order by from the criteria query temporarily for the operation? Perhaps when the query sees the rowcount projection?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 14, 2007 9:21 am 
Newbie

Joined: Mon Jan 29, 2007 2:03 am
Posts: 11
Quote:
ISession session = _sessionManager.OpenSession();
ISession innerSession = ((SessionDelegate)session).InnerSession;
queryObject.SetProjection(Projections.RowCount());
ICriteria criteria = queryObject.GetExecutableCriteria(innerSession);
criteria.SetFirstResult(0);
int rowCount = (int)criteria.UniqueResult();
queryObject.SetProjection(null);
queryObject.SetResultTransformer(CriteriaUtil.RootEntity);
return rowCount;


hi,

which portion from your query you're issuing an order by?

[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 14, 2007 9:56 pm 
Beginner
Beginner

Joined: Tue Dec 20, 2005 9:40 pm
Posts: 20
queryObject is a DetachedQuery in which I've created an order by


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.