-->
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: Count (number of rows) with custom query with setFirstResult
PostPosted: Wed Sep 13, 2006 5:52 am 
Newbie

Joined: Wed Sep 13, 2006 5:24 am
Posts: 3
I use named SQL query with very complicated syntax and long-timed to execute (using inner selects and MS SQL contains).

Then IQuery query = context.Session.GetNamedQuery("QueryName"); is used.
For selecting only required results following code is used.

query.SetFirstResult(5);
query.SetMaxResults(15);

As I understand, sql query is executed, result set contains all records (all rows) and only 5-15 of them are mapped to objects by NHibernate. Obviously, NHibernate does not add anything to SQL query (for example SELECT TOP x).
Is it right? Does NHibernate uses some specific technic to perform setFirstResult?

Then - is it possible to get the amount of total rows returned (not mapped)? I do not want to execute the same query with select count(*) again in addition to previous call. Is it possible? Probably, what is needed is to get affected rows count only.

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.