<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Must Everything Be Virtual With NHibernate?</title> <atom:link href="http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/feed/" rel="self" type="application/rss+xml" /><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/</link> <description>inquisitive: adjective. given to inquiry, research, or asking questions; eager for knowledge; intellectually curious</description> <lastBuildDate>Wed, 08 Feb 2012 11:42:42 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Setting up NHibernate with SQLite using Visual Studio 2010 and NuGet &#124; Coding Journal</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-2/#comment-101839</link> <dc:creator>Setting up NHibernate with SQLite using Visual Studio 2010 and NuGet &#124; Coding Journal</dc:creator> <pubDate>Tue, 25 Oct 2011 22:54:27 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-101839</guid> <description>[...] Note the virtual keyword everywhere. Must everything be virtual with NHibernate? [...]</description> <content:encoded><![CDATA[<p>[...] Note the virtual keyword everywhere. Must everything be virtual with NHibernate? [...]</p> ]]></content:encoded> </item> <item><title>By: Alejandro Payares</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-101322</link> <dc:creator>Alejandro Payares</dc:creator> <pubDate>Tue, 13 Sep 2011 14:35:00 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-101322</guid> <description>Very clean and precise explanation. Thanks! </description> <content:encoded><![CDATA[<p>Very clean and precise explanation. Thanks! </p> ]]></content:encoded> </item> <item><title>By: YiWei _ reproduced: I feel to NHibernate (2) : why should fully everywhere</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-101253</link> <dc:creator>YiWei _ reproduced: I feel to NHibernate (2) : why should fully everywhere</dc:creator> <pubDate>Thu, 08 Sep 2011 05:49:25 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-101253</guid> <description>[...] you see the NHibernate development team membersDavy BrionArticle&quot;Must Everything be Virtual with NHiberante？&quot;Later, I know their design ideas-although I still don&#8217;t agree.I really don&#8217;t like [...]</description> <content:encoded><![CDATA[<p>[...] you see the NHibernate development team membersDavy BrionArticle&quot;Must Everything be Virtual with NHiberante？&quot;Later, I know their design ideas-although I still don&#8217;t agree.I really don&#8217;t like [...]</p> ]]></content:encoded> </item> <item><title>By: Build Your Own Data Access Layer: Lazy Loading</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-101139</link> <dc:creator>Build Your Own Data Access Layer: Lazy Loading</dc:creator> <pubDate>Sun, 04 Sep 2011 11:04:14 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-101139</guid> <description>[...] NHibernate has a similar restriction and i&#039;ve tried to explain the reasons behind this in this post.I&#039;m not sure if i succeeded in explaining this topic in a simple and clear manner, but this [...]</description> <content:encoded><![CDATA[<p>[...] NHibernate has a similar restriction and i&#039;ve tried to explain the reasons behind this in this post.I&#039;m not sure if i succeeded in explaining this topic in a simple and clear manner, but this [...]</p> ]]></content:encoded> </item> <item><title>By: Why NHibernate Entities Need A Public Or Protected Parameterless Constructor</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-101135</link> <dc:creator>Why NHibernate Entities Need A Public Or Protected Parameterless Constructor</dc:creator> <pubDate>Sun, 04 Sep 2011 10:36:49 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-101135</guid> <description>[...] then NHibernate will create a type which inherits from your entity (this is described in depth here and here). Which means that we really need either a public or protected constructor in entity [...]</description> <content:encoded><![CDATA[<p>[...] then NHibernate will create a type which inherits from your entity (this is described in depth here and here). Which means that we really need either a public or protected constructor in entity [...]</p> ]]></content:encoded> </item> <item><title>By: Karl Cassar</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-99519</link> <dc:creator>Karl Cassar</dc:creator> <pubDate>Wed, 01 Jun 2011 22:36:00 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-99519</guid> <description>A small note to anyone reading this in the future - One can easily bypass the virtual checking by adding the property &#039;use_proxy_validator&#039; set to false in the nhibernate config.config.SetProperty(NHibernate.Cfg.Environment.UseProxyValidator, &quot;false&quot;);http://www.nhforge.org/doc/nh/en/index.html - Section 3.5.2</description> <content:encoded><![CDATA[<p>A small note to anyone reading this in the future &#8211; One can easily bypass the virtual checking by adding the property &#8216;use_proxy_validator&#8217; set to false in the nhibernate config.</p><p>config.SetProperty(NHibernate.Cfg.Environment.UseProxyValidator, &#8220;false&#8221;);</p><p><a
href="http://www.nhforge.org/doc/nh/en/index.html -" rel="nofollow">http://www.nhforge.org/doc/nh/en/index.html -</a> Section 3.5.2</p> ]]></content:encoded> </item> <item><title>By: fluent nhibernate mappning &#124; Maffelu.net</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-99332</link> <dc:creator>fluent nhibernate mappning &#124; Maffelu.net</dc:creator> <pubDate>Sun, 22 May 2011 16:28:37 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-99332</guid> <description>[...] Det enda man måste tänka på är att göra egenskaperna virtual så att nHibernate kan skapa sina proxy klasser. För att skapa mappningen så måste vi ha i åtanke att vi faktiskt jobbar med arv och att även [...]</description> <content:encoded><![CDATA[<p>[...] Det enda man måste tänka på är att göra egenskaperna virtual så att nHibernate kan skapa sina proxy klasser. För att skapa mappningen så måste vi ha i åtanke att vi faktiskt jobbar med arv och att även [...]</p> ]]></content:encoded> </item> <item><title>By: Theo de Roo</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-71483</link> <dc:creator>Theo de Roo</dc:creator> <pubDate>Tue, 09 Nov 2010 04:36:17 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-71483</guid> <description>This is all well and good and very useful, until the classes you want to map to NHibernate implement for example INotifyPropertyChanged (crucial for data-binding). Events have to be declared virtual as well for NH to be able to make proxies. However, when you happen to be developing in VB2005/2008/2010 then you know that the compiler does not allow you to define events (even custom events) as virtual/overridable! So why does NH need to have events virtual as well? Because the proxy instance is not the same .NET instance as the initialized proxy. Hence, any control which subscribes to the event of an object, could be subscribing to a proxy. However once the event fires it does so from another instance, hence you would never receive it. My solution is to create a C# base class which implements INotifyPropertyChanged and allows virtual events. And have all my VB classes inherit from it. Stupid, strange and frustrating, but hence is the standardisation across .NET compilers...</description> <content:encoded><![CDATA[<p>This is all well and good and very useful, until the classes you want to map to NHibernate implement for example INotifyPropertyChanged (crucial for data-binding). Events have to be declared virtual as well for NH to be able to make proxies. However, when you happen to be developing in VB2005/2008/2010 then you know that the compiler does not allow you to define events (even custom events) as virtual/overridable! So why does NH need to have events virtual as well? Because the proxy instance is not the same .NET instance as the initialized proxy. Hence, any control which subscribes to the event of an object, could be subscribing to a proxy. However once the event fires it does so from another instance, hence you would never receive it. My solution is to create a C# base class which implements INotifyPropertyChanged and allows virtual events. And have all my VB classes inherit from it. Stupid, strange and frustrating, but hence is the standardisation across .NET compilers&#8230;</p> ]]></content:encoded> </item> <item><title>By: Starting NHibernate &#124; Adding DLLs, Mapping Tables to Objects &#171; CowFarm.NET</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-51504</link> <dc:creator>Starting NHibernate &#124; Adding DLLs, Mapping Tables to Objects &#171; CowFarm.NET</dc:creator> <pubDate>Thu, 05 Aug 2010 14:00:52 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-51504</guid> <description>[...] The dumb answer to the first question is because Nhibernate will throw a &#8220;NHibernate.InvalidProxyTypeException&#8220;. This goes for anything that is exposed outside of your Object. The fastest answer I can give you is, in order to lazily load your objects. Many blogs already cover why, I recommend reading Davy Brion&#8217;s Blog post: Must everything be virtual with nhibernate?. [...]</description> <content:encoded><![CDATA[<p>[...] The dumb answer to the first question is because Nhibernate will throw a &#8220;NHibernate.InvalidProxyTypeException&#8220;. This goes for anything that is exposed outside of your Object. The fastest answer I can give you is, in order to lazily load your objects. Many blogs already cover why, I recommend reading Davy Brion&#8217;s Blog post: Must everything be virtual with nhibernate?. [...]</p> ]]></content:encoded> </item> <item><title>By: Tony S</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-42824</link> <dc:creator>Tony S</dc:creator> <pubDate>Wed, 23 Jun 2010 12:47:19 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-42824</guid> <description>In the NH mapping files on the class eleent there is an attribute named &quot;proxy&quot;.
This will allow you to use an interface to desctibe which properies/methods you want to lazy load.I do agree any objects the UI consumes should be DTO&#039;s, and this would also negate some of the issues.</description> <content:encoded><![CDATA[<p>In the NH mapping files on the class eleent there is an attribute named &#8220;proxy&#8221;.<br
/> This will allow you to use an interface to desctibe which properies/methods you want to lazy load.</p><p>I do agree any objects the UI consumes should be DTO&#8217;s, and this would also negate some of the issues.</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-39409</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Mon, 17 May 2010 15:21:07 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-39409</guid> <description>@Mathieuhttp://davybrion.com/blog/2010/05/why-you-shouldnt-expose-your-entities-through-your-services/</description> <content:encoded><![CDATA[<p>@Mathieu</p><p><a
href="http://davybrion.com/blog/2010/05/why-you-shouldnt-expose-your-entities-through-your-services/" rel="nofollow">http://davybrion.com/blog/2010/05/why-you-shouldnt-expose-your-entities-through-your-services/</a></p> ]]></content:encoded> </item> <item><title>By: Mathieu Clerte</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-39335</link> <dc:creator>Mathieu Clerte</dc:creator> <pubDate>Sun, 16 May 2010 13:14:28 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-39335</guid> <description>DTO? No... Why?My issue was that in my DataAccess Layer I have Entities loaded using Criteria API, lazy=true, and those are returned in the Service Layer, which serialize (WCF) the entity , thus accessing the properties, which trigger the proxy crap.I just want the serializer to access the property as it is , without re-querying the DB as we are now in the service layer and not in the DAL. I don&#039;t want to make changes at the serializer level.In my opinion, using DTO in this case is a too bulky solution...- create a new DTO class for each specific need leads to a huge number of class at the end unmanageable- filling DTO from Entities require either a deep copy / recursive reflection / (serialization/deserialization) operation which is very consumingIn my case I absolutely want to return the Entities but i need a way :- either to remove the proxy crap from the entity (I found &lt;a href=&quot;//maherkilani.blogspot.com/2008/12/hibernate-proxy-cleaner.html\&quot; rel=&quot;nofollow&quot;&gt; this Hibernate proxy cleaner&lt;/a&gt; that I need to convert for NHibernate in C#.- either to disable the proxy so that IF the NHibernate session is closed, the proxy does NOT try to retreive any data (I think this is missing from nhib.)If anyone has ideas....</description> <content:encoded><![CDATA[<p>DTO? No&#8230; Why?</p><p>My issue was that in my DataAccess Layer I have Entities loaded using Criteria API, lazy=true, and those are returned in the Service Layer, which serialize (WCF) the entity , thus accessing the properties, which trigger the proxy crap.</p><p>I just want the serializer to access the property as it is , without re-querying the DB as we are now in the service layer and not in the DAL. I don&#8217;t want to make changes at the serializer level.</p><p>In my opinion, using DTO in this case is a too bulky solution&#8230;</p><p>- create a new DTO class for each specific need leads to a huge number of class at the end unmanageable</p><p>- filling DTO from Entities require either a deep copy / recursive reflection / (serialization/deserialization) operation which is very consuming</p><p>In my case I absolutely want to return the Entities but i need a way :</p><p>- either to remove the proxy crap from the entity (I found <a
href="//maherkilani.blogspot.com/2008/12/hibernate-proxy-cleaner.html\" rel="nofollow"> this Hibernate proxy cleaner</a> that I need to convert for NHibernate in C#.</p><p>- either to disable the proxy so that IF the NHibernate session is closed, the proxy does NOT try to retreive any data (I think this is missing from nhib.)</p><p>If anyone has ideas&#8230;.</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-38899</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 12 May 2010 06:57:33 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-38899</guid> <description>@Ciaranwhy even send the entities over a WCF service anyway? you&#039;re much better off mapping to DTO&#039;s and sending them over the wire. You&#039;ll have complete control over what gets sent and what doesn&#039;t.</description> <content:encoded><![CDATA[<p>@Ciaran</p><p>why even send the entities over a WCF service anyway? you&#8217;re much better off mapping to DTO&#8217;s and sending them over the wire. You&#8217;ll have complete control over what gets sent and what doesn&#8217;t.</p> ]]></content:encoded> </item> <item><title>By: Ciaran</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-38893</link> <dc:creator>Ciaran</dc:creator> <pubDate>Wed, 12 May 2010 05:56:37 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-38893</guid> <description>I&#039;ve been trying to disable lazy loading in nHibernate as I&#039;m storing some blobs in my database.  So I have a Document table and a DocumentContent table. Document contains a filename, description etc and has a DocumentContent property.I have a Silverlight client, so I don&#039;t want to load up and send the DocumentContent to the client unless I explicity ask for it, but I&#039;m having trouble doing this.  In WCF serialization the DocumentContent property will be touched and so gets lazily loaded then.  I&#039;m trying to turn this off and have added lazy=false and removed virtual from my classes but it&#039;s still loading :(I have a posting on StackOverflow about this and would be grateful if you could have a look:  http://stackoverflow.com/questions/2816243/prevent-lazy-loading-in-nhibernate</description> <content:encoded><![CDATA[<p>I&#8217;ve been trying to disable lazy loading in nHibernate as I&#8217;m storing some blobs in my database.  So I have a Document table and a DocumentContent table. Document contains a filename, description etc and has a DocumentContent property.</p><p>I have a Silverlight client, so I don&#8217;t want to load up and send the DocumentContent to the client unless I explicity ask for it, but I&#8217;m having trouble doing this.  In WCF serialization the DocumentContent property will be touched and so gets lazily loaded then.  I&#8217;m trying to turn this off and have added lazy=false and removed virtual from my classes but it&#8217;s still loading <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /></p><p>I have a posting on StackOverflow about this and would be grateful if you could have a look: <a
href="http://stackoverflow.com/questions/2816243/prevent-lazy-loading-in-nhibernate" rel="nofollow">http://stackoverflow.com/questions/2816243/prevent-lazy-loading-in-nhibernate</a></p> ]]></content:encoded> </item> <item><title>By: 1000niaz نيازمنديها</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-37972</link> <dc:creator>1000niaz نيازمنديها</dc:creator> <pubDate>Sun, 02 May 2010 20:47:43 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-37972</guid> <description>btw, you can just as easily get a proxy without going through an association by calling session.Load instead of session.Get.</description> <content:encoded><![CDATA[<p>btw, you can just as easily get a proxy without going through an association by calling session.Load instead of session.Get.</p> ]]></content:encoded> </item> <item><title>By: Afshar Mohebbi</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-37558</link> <dc:creator>Afshar Mohebbi</dc:creator> <pubDate>Wed, 28 Apr 2010 11:11:47 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-37558</guid> <description>Thanks Davy,
We turned our lazy-disable Nhibernate application into lazy with this good blog post.</description> <content:encoded><![CDATA[<p>Thanks Davy,<br
/> We turned our lazy-disable Nhibernate application into lazy with this good blog post.</p> ]]></content:encoded> </item> <item><title>By: Starting NHibernate &#124; Mapping Tables to Objects &#171; CowFarm.NET</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-36914</link> <dc:creator>Starting NHibernate &#124; Mapping Tables to Objects &#171; CowFarm.NET</dc:creator> <pubDate>Wed, 21 Apr 2010 20:06:26 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-36914</guid> <description>[...] The dumb answer to the first question is because Nhibernate will throw a &#8220;NHibernate.InvalidProxyTypeException&#8220;. This goes for anything that is exposed outside of your Object. The fastest answer I can give you is, in order to lazily load your objects. Many blogs already cover why, I recommend reading Davy Brion&#8217;s Blog post: Must everything be virtual with nhibernate?. [...]</description> <content:encoded><![CDATA[<p>[...] The dumb answer to the first question is because Nhibernate will throw a &#8220;NHibernate.InvalidProxyTypeException&#8220;. This goes for anything that is exposed outside of your Object. The fastest answer I can give you is, in order to lazily load your objects. Many blogs already cover why, I recommend reading Davy Brion&#8217;s Blog post: Must everything be virtual with nhibernate?. [...]</p> ]]></content:encoded> </item> <item><title>By: My first NHibernate application &#171; Dilhan&#39;s Blog</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-33411</link> <dc:creator>My first NHibernate application &#171; Dilhan&#39;s Blog</dc:creator> <pubDate>Wed, 24 Mar 2010 08:55:34 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-33411</guid> <description>[...] can create required proxy class for our class types. For more info about this please read this post by Davi Brion. Also the collection types shuold be IList&lt;&gt; or ISet. (e.g. [...]</description> <content:encoded><![CDATA[<p>[...] can create required proxy class for our class types. For more info about this please read this post by Davi Brion. Also the collection types shuold be IList&lt;&gt; or ISet. (e.g. [...]</p> ]]></content:encoded> </item> <item><title>By: Setting up Table/Object mappings using Fluent nHibernate &#8211; Matt Long (.com.au)</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-27776</link> <dc:creator>Setting up Table/Object mappings using Fluent nHibernate &#8211; Matt Long (.com.au)</dc:creator> <pubDate>Mon, 08 Feb 2010 19:21:32 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-27776</guid> <description>[...] proxies to achieve its Lazy Loading feature.&#160; This is a bit beyond the scope of this post, but Davy Brion offers a pretty detailed explination, The quick answer to that question is: because we need members to be virtual in order to do our [...]</description> <content:encoded><![CDATA[<p>[...] proxies to achieve its Lazy Loading feature.&#160; This is a bit beyond the scope of this post, but Davy Brion offers a pretty detailed explination, The quick answer to that question is: because we need members to be virtual in order to do our [...]</p> ]]></content:encoded> </item> <item><title>By: Must Everything Be Virtual With NHibernate, Part II &#124; The Inquisitive Coder &#8211; Davy Brion&#8217;s Blog</title><link>http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/comment-page-1/#comment-22599</link> <dc:creator>Must Everything Be Virtual With NHibernate, Part II &#124; The Inquisitive Coder &#8211; Davy Brion&#8217;s Blog</dc:creator> <pubDate>Wed, 23 Sep 2009 04:56:39 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1210#comment-22599</guid> <description>[...] already tried to explain this before, but here&#8217;s a simple example from a presentation i recently did on [...]</description> <content:encoded><![CDATA[<p>[...] already tried to explain this before, but here&#8217;s a simple example from a presentation i recently did on [...]</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 3/25 queries in 0.021 seconds using disk: basic
Object Caching 641/644 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d18sni7re4ly7f.cloudfront.net

Served from: davybrion.com @ 2012-02-08 19:21:47 -->
