-->
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: Thats not lazy-loading, isn't it?
PostPosted: Thu May 15, 2008 2:30 pm 
Newbie

Joined: Thu Jul 05, 2007 9:44 am
Posts: 4
Hello

I'm using nhibernate 1.2 with asp.net 2.0, MSSQL 2005.

An Object Question has Answers, Responses, Users which answered, etc.

a GetQuestion takes up to 14 seconds!

In the hibernate-debug-log i see, that there are thousends of SQL-Queries with one GetQuestion. For each answer of the Answer-Collection, each User of the Users-Collection, each Users Questions and so on... the whole Tree of a Question-Object. The Logfile of one GetQuestion reaches nearly 100MB.

That can't be lazy-loading, no?

i expected only one sql-query and the queries for the collected objects then when they are used..

With version 1.2, lazy-loading should be active per default. Inserting lazy="true" or lazy="false" at the collection-mapping or in the class-definition changes nothing.

Must lazy-loading be activated anywhere else?

Thank you very much for helping and sorry about bad english.

Patrick

Here's a snapping from the question-xml definition file:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    namespace="....." assembly="business" >
  <class name="Question" table="t_question">
...
<many-to-one name="User" column="user_id" not-null="true" class=".....User" />
    <set name="Answers"  table="t_answer" cascade="all" inverse="true"  order-by="pos asc" >
      <key column="question_id" />
      <one-to-many class="......Answer"  />
    </set>
    <set name="Responses"  table="t_response"  order-by="CreationDate desc" >
      <key column="question_id" />
      <one-to-many class=".....Response" />
    </set>
...
...


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 4:48 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
I have the simmilar issue, I get two selects executed, one for parent and one for children. I though that I would get, as I iterate through collection, one select per child. Setting lazy flag makes no difference.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 4:49 pm 
Newbie

Joined: Fri Mar 28, 2008 2:37 pm
Posts: 4
Location: Toronto
Try removing the order by


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 4:55 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
I have the simmilar issue, I get two selects executed, one for parent and one for children. I though that I would get, as I iterate through collection, one select per child. Setting lazy flag makes no difference.


Top
 Profile  
 
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.