-->
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.  [ 5 posts ] 
Author Message
 Post subject: Why does nhibernate send a request per line of my table
PostPosted: Sun Jul 22, 2007 10:05 pm 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Hello,
I write this :

IQuery query = session.CreateQuery("select c from Customer as c");
var result = query.Enumerable<Customer>().ToList();

As I show sql generated by nhibernate, I realized that it sends a request per lines of my customer table :

NHibernate: SELECT customer0_.clicocl as clicocl0_0_, customer0_.clidcfa as clid
cfa0_0_, customer0_.cliddfa as cliddfa0_0_ FROM clients customer0_ WHERE custome
r0_.clicocl=?; p0 = '1'
NHibernate: SELECT customer0_.clicocl as clicocl0_0_, customer0_.clidcfa as clid
cfa0_0_, customer0_.cliddfa as cliddfa0_0_ FROM clients customer0_ WHERE custome
r0_.clicocl=?; p0 = '2'

...

So it is very slow to collect all my customers...

Why don't it just send something like this:
select * from customers

Should I write things differently ?

thanks for any help,

mathmax


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 23, 2007 1:03 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You should use List() instead of Enumerable(). Any particular reason you decided to go with Enumerable()?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 23, 2007 6:01 am 
Regular
Regular

Joined: Wed Apr 25, 2007 4:18 am
Posts: 51
Location: Belarus, Gomel
Hi sergey!

I suppose the main reason to use Enumerable() - is it's ability to "stop at any time" - so you may request 1 billion records table, but stop processing after retreiving 10 objects :)

_________________
WBR, Igor


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 23, 2007 7:47 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
You are right. Using List creat only one request, but why ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 23, 2007 8:54 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This is answered in the documentation.


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