﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description>Sternr,
  
Nope, the problem with doing those things in the mapping is that they are global.
  
See my post about the different scenarios and how they do not apply
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment23</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment23</guid><pubDate>Sun, 08 Aug 2010 20:05:32 GMT</pubDate></item><item><title>sternr commented on NHibernate is lazy, just live with it</title><description>Maybe I'm missing something, but you seem a bit harsh on lazy=false.
  
  
In cases where you know related entities are needed, lazy-loading has massive performance implications, especially in cases of smart client applications where server connectivity comes at great cost.
  
  
Your client was right in mapping it's entities with lazy="false", his only mistake was not setting the fetch mode.
  
  
I agree the decision not to lazy load has great implications, and should be dealt with care, but there is a great distance from getting the goosebumps over it.
  
  
The main lesson we ought to learn from your client is not " we *heart* lazy", but "NHibernate is not magic". or in short RTFM ;)
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment22</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment22</guid><pubDate>Sun, 08 Aug 2010 15:35:17 GMT</pubDate></item><item><title>Adam commented on NHibernate is lazy, just live with it</title><description>I agree @sql. For straight entities stored in the database, using nhib is great. Insert, update and query are very easy. As soon as you have any other query (most others), writing a sql statement and mapping that using linq is far easier.
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment21</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment21</guid><pubDate>Sat, 07 Aug 2010 08:13:51 GMT</pubDate></item><item><title>Frans Bouma commented on NHibernate is lazy, just live with it</title><description>Dmitry:
  
Yes, null. Because you didn't fetch it and lazy loading isn't loading it. That's why a proper eager loading strategy is essential, e.g. through prefetch paths, Includes or what have you.
  
  
(so you'd issue 3 queries, one for each entity type and merge them internally)
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment20</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment20</guid><pubDate>Fri, 06 Aug 2010 16:54:47 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description>Mark,
  
Two reasons, backward compatibility and that there _are_ scenarios where you want that.
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment19</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment19</guid><pubDate>Fri, 06 Aug 2010 07:24:31 GMT</pubDate></item><item><title>Mark commented on NHibernate is lazy, just live with it</title><description>So, playing devils advocate, if default_lazy=false is so bad, why does NH allow you to do it ? 
  
I understand in specific instances there might be a reason to override a relationship so that it isn't lazy loaded, but from whats said here there is no reason to have a default of default_lazy=false.
  
  
I'm reading alot of NH stuff recently which says "x is bad, don't do it", seems the tweaking and configuration of NH adds a fairly significant overhead to any project.
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment18</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment18</guid><pubDate>Fri, 06 Aug 2010 07:11:03 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description>John,
  
  
The way NHibernate work, it has to process each loaded entity immediately, because that entity is being exposed to user code.
  
So before the entire list is done, it has to process all the work for the entity. It doesn't have the chance to look at everything.
  
  
The problem then becomes that you set lazy=false, didn't set fetch (so it is at the default select), which instruct NH to issue a separate select.
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment17</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment17</guid><pubDate>Wed, 04 Aug 2010 19:26:15 GMT</pubDate></item><item><title>Dmitry commented on NHibernate is lazy, just live with it</title><description>Frans,
  
  
If you set the mapping to "lazy=true" and do not eagerly load parts, what would be the Parts property set to? Setting it to null is something EF 1.0 tried to do and is a bad idea because you end up with a broken model. Do you throw an exception? I am not sure I like it either.
  
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment16</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment16</guid><pubDate>Wed, 04 Aug 2010 19:10:58 GMT</pubDate></item><item><title>John Farrell commented on NHibernate is lazy, just live with it</title><description>I'm surprised NHIbernate doesn't efficiently eagerly load graphs via joins.  
  
I couldn't live without this feature in EF.
  
  
The answer to Damien seems a bit weird.  Why wouldn't NHibernate not know about further polymorphic collections or other nonsense?   Aren't these things set up in the mapping files?
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment15</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment15</guid><pubDate>Wed, 04 Aug 2010 17:58:33 GMT</pubDate></item><item><title>depaulo commented on NHibernate is lazy, just live with it</title><description>So what is the answer? What should he actually have done in this situation to load all that data? It is a problem we come across a lot.
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment14</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment14</guid><pubDate>Wed, 04 Aug 2010 16:47:03 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description>Frans,
  
Also note that NH make a distinction between lazy=true/false and how to eagerly load things fetch=join/select
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment13</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment13</guid><pubDate>Wed, 04 Aug 2010 16:04:30 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description>Frans,
  
It has to load that because the mapping explicitly told it to.
  
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment12</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment12</guid><pubDate>Wed, 04 Aug 2010 16:04:07 GMT</pubDate></item><item><title>SQL commented on NHibernate is lazy, just live with it</title><description>Makes writing standard SQL seem appealing.
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment11</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment11</guid><pubDate>Wed, 04 Aug 2010 16:04:05 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description>Damien,
  
Because it is too early for NH to know.
  
Imagine a polymorphic query that load some things with different collections, for example
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment10</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment10</guid><pubDate>Wed, 04 Aug 2010 16:03:17 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description>Frank,
  
I didn't write the blog, and the blog isn't using NH, so I have no idea
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment9</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment9</guid><pubDate>Wed, 04 Aug 2010 16:02:07 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description> João P. Bragança,
  
Read the post, you shouldn't use lazy=false
  
  
If you are using reporting only model with no associations, then lazy=false is still isn't right.
  
It wouldn't do anything, anyway
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment8</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment8</guid><pubDate>Wed, 04 Aug 2010 16:01:41 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate is lazy, just live with it</title><description>Jason,
  
It is eventually perf. It is also limiting what NH can do.
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment7</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment7</guid><pubDate>Wed, 04 Aug 2010 16:00:47 GMT</pubDate></item><item><title>Frans Bouma commented on NHibernate is lazy, just live with it</title><description>I don't really see why NHibernate needs to fetch Parts etc. when the query doesn't refer to it. In fact, by doing so (and thus resulting in 400 queries) it is doing lazy loading (load on demand) while there's actually no need for it. 
  
  
If you switch off lazy loading, like in the mapping file, the developer should instead EAGER load the data of the graphs. The queries generated now are the same as when he'd traverse the rows and access the Parts collection, wouldn't it? He also could have solved this by using a fetch strategy btw, not ideal either (always eager loading isn't ideal).
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment6</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment6</guid><pubDate>Wed, 04 Aug 2010 15:36:22 GMT</pubDate></item><item><title>Damien Guard commented on NHibernate is lazy, just live with it</title><description>Why isn't NHibernate's second query set a single query with an IN clause?
  
  
Yes, it would still return too much data but at least there would be less overhead/latency.
  
  
[)amien
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment5</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment5</guid><pubDate>Wed, 04 Aug 2010 14:46:47 GMT</pubDate></item><item><title>Frank Quednau commented on NHibernate is lazy, just live with it</title><description>When you load this page, do you have a content -&gt; comment association and do you load the comments lazily? or do you load the content and the comments at once and display it?
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment4</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment4</guid><pubDate>Wed, 04 Aug 2010 14:33:47 GMT</pubDate></item><item><title>Jo&amp;#227;o P. Bragan&amp;#231;a commented on NHibernate is lazy, just live with it</title><description>Could you talk more about which scenarios where lazy=false should be used? For example I am using nhibernate for a reporting only model, no associations. Does lazy=false make sense here?
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment3</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment3</guid><pubDate>Wed, 04 Aug 2010 14:28:47 GMT</pubDate></item><item><title>Jason Y commented on NHibernate is lazy, just live with it</title><description>Is the downside of lazy=false strictly performance in this case?  (I'm not implying that performance is unimportant.)
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment2</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment2</guid><pubDate>Wed, 04 Aug 2010 14:23:04 GMT</pubDate></item><item><title>Richard Dingwall commented on NHibernate is lazy, just live with it</title><description>I think it is a common misconception that NHibernate is simpler without lazy loading. But actually I think it is far more difficult to get right - especially when you throw in further non-lazy 'simplifications' like treating sessions as transient in your architecture and using disconnected objects (preventing you from ever enabling lazy loading again).
  
  
Glad you wrote about it, now I can clobber people with a link next time
</description><link>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment1</link><guid>http://ayende.com/4573/nhibernate-is-lazy-just-live-with-it#comment1</guid><pubDate>Wed, 04 Aug 2010 12:33:49 GMT</pubDate></item></channel></rss>