-->
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.  [ 4 posts ] 
Author Message
 Post subject: count
PostPosted: Fri Oct 14, 2005 11:57 am 
Hi,

I am new to use nhibernate.
I have try to find with search on forum and with some google help but nothing so you are my last chance.
I try to just make a count on a table.
for that i do not want to load all table and make count after.
I need to have optimise thing...
I have try :
Code:
public int GetObjectCount(Type objectType)
      {
         session = factory.OpenSession();
         session.BeginTransaction();
         return (int) session.CreateQuery("select count(*) from "+objectType.ToString()).UniqueResult();
      }

I have finnaly done that but it is not object oriented.
So I am sure it is possible to set table (FROM) with createcriteria and after filter what we want (SELECT) with a function to say what i want is count(*) but I have not found.

thanks by advance for any answer.


Top
  
 
 Post subject:
PostPosted: Tue Oct 18, 2005 10:32 am 
any idea?
UP

:lol:


Top
  
 
 Post subject:
PostPosted: Tue Oct 18, 2005 12:08 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
Count on ICriteria is not available yet. I believe that is post 1.0 enhancement. Hopefully that will be one of the first things worked on. It would be very usefull for paging code.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 8:40 am 
thanks for reply so i wait for it ;)


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.