<?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: Assigning Foreign Keys In NHibernate</title> <atom:link href="http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/feed/" rel="self" type="application/rss+xml" /><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/</link> <description>inquisitive: adjective. given to inquiry, research, or asking questions; eager for knowledge; intellectually curious</description> <lastBuildDate>Sun, 20 May 2012 21:55:00 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Geert V</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-23227</link> <dc:creator>Geert V</dc:creator> <pubDate>Tue, 15 Dec 2009 08:11:09 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-23227</guid> <description>Thanks Davy, this solved a lot of unneeded queries!</description> <content:encoded><![CDATA[<p>Thanks Davy, this solved a lot of unneeded queries!</p> ]]></content:encoded> </item> <item><title>By: Whut</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-22758</link> <dc:creator>Whut</dc:creator> <pubDate>Mon, 19 Oct 2009 20:45:22 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-22758</guid> <description>Thanks for answer. I won&#039;t ask any more questions before ending up reading of NHibernate Reference Guide.This Update method mislead me because of the Update method in your series about writing custom DAL. BTW. Those posts saved me from writing more hand coded &quot;Active Record&quot; entities for my SharePoint project, now I have my own SharePointHibernate:)</description> <content:encoded><![CDATA[<p>Thanks for answer. I won&#8217;t ask any more questions before ending up reading of NHibernate Reference Guide.</p><p>This Update method mislead me because of the Update method in your series about writing custom DAL. BTW. Those posts saved me from writing more hand coded &#8220;Active Record&#8221; entities for my SharePoint project, now I have my own SharePointHibernate:)</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-22755</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Mon, 19 Oct 2009 19:26:32 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-22755</guid> <description>NHibernate tries to defer sending statements to the database as long as possible. If possible, it will wait until the session is flushed or the transaction is committed (depending on the FlushMode setting).The Update method itself doesn&#039;t really mean &quot;send an update statement for this instance to the database&quot;. It&#039;s basically a way of attaching a detached entity to the current ISession (or, registering an unregistered instance in the current Unit Of Work if you prefer those terms). In fact, NHibernate will try to update the instance of any persistent object if it has been changed once the session is flushed (or the transaction is committed) even if you don&#039;t call the Update method.  Since the product instance was retrieved through the session, it is already a persistent object and NHibernate will automatically persist any changes to that instance to the database.I think you should read up on how NHibernate&#039;s Unit Of Work implementation (basically your session) works, and how it deals with persistence of entities based on their state (transient, persistent or detached).</description> <content:encoded><![CDATA[<p>NHibernate tries to defer sending statements to the database as long as possible. If possible, it will wait until the session is flushed or the transaction is committed (depending on the FlushMode setting).</p><p>The Update method itself doesn&#8217;t really mean &#8220;send an update statement for this instance to the database&#8221;. It&#8217;s basically a way of attaching a detached entity to the current ISession (or, registering an unregistered instance in the current Unit Of Work if you prefer those terms). In fact, NHibernate will try to update the instance of any persistent object if it has been changed once the session is flushed (or the transaction is committed) even if you don&#8217;t call the Update method.  Since the product instance was retrieved through the session, it is already a persistent object and NHibernate will automatically persist any changes to that instance to the database.</p><p>I think you should read up on how NHibernate&#8217;s Unit Of Work implementation (basically your session) works, and how it deals with persistence of entities based on their state (transient, persistent or detached).</p> ]]></content:encoded> </item> <item><title>By: Whut</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-22754</link> <dc:creator>Whut</dc:creator> <pubDate>Mon, 19 Oct 2009 19:11:03 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-22754</guid> <description>Why in below example product&#039;s Category won&#039;t be updated?? Checked in NHibernate 2.1. For me it&#039;s a bug.Product product = session.Get(productId);
product.Category = session.Load&lt;ProductCategory&gt;(categoryId); (// or session.Get...
session.&lt;em&gt;Update&lt;/em&gt;(product);When I use session.Flush(), product&#039;s Category will be updated.</description> <content:encoded><![CDATA[<p>Why in below example product&#8217;s Category won&#8217;t be updated?? Checked in NHibernate 2.1. For me it&#8217;s a bug.</p><p>Product product = session.Get(productId);<br
/> product.Category = session.Load&lt;ProductCategory&gt;(categoryId); (// or session.Get&#8230;<br
/> session.<em>Update</em>(product);</p><p>When I use session.Flush(), product&#8217;s Category will be updated.</p> ]]></content:encoded> </item> <item><title>By: David</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-11799</link> <dc:creator>David</dc:creator> <pubDate>Thu, 09 Apr 2009 10:29:11 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-11799</guid> <description>Fair enough.  I guess the use cases I&#039;m thinking of involve relatively static data, but I agree with your reservations.  Still, thanks for sharing the approach!</description> <content:encoded><![CDATA[<p>Fair enough.  I guess the use cases I&#8217;m thinking of involve relatively static data, but I agree with your reservations.  Still, thanks for sharing the approach!</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-11434</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Mon, 06 Apr 2009 05:03:40 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-11434</guid> <description>@Davidif the record whose Id you&#039;re using no longer exists, i prefer to throw an exception with a meaningful message. If you use the proxy approach to avoid the database hit, you&#039;d get a relatively obscure exception message if the foreign key value turns out to be invalid.as for the caching... i try to do that only where it really makes sense, never as a general approach</description> <content:encoded><![CDATA[<p>@David</p><p>if the record whose Id you&#8217;re using no longer exists, i prefer to throw an exception with a meaningful message. If you use the proxy approach to avoid the database hit, you&#8217;d get a relatively obscure exception message if the foreign key value turns out to be invalid.</p><p>as for the caching&#8230; i try to do that only where it really makes sense, never as a general approach</p> ]]></content:encoded> </item> <item><title>By: David</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-11423</link> <dc:creator>David</dc:creator> <pubDate>Mon, 06 Apr 2009 02:17:16 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-11423</guid> <description>Nice, I&#039;d wondered about doing something like this for handling selections from a combo/drop-down.Out of curiosity, why don&#039;t you like this approach?  Would you prefer to cache the referenced object(s)?</description> <content:encoded><![CDATA[<p>Nice, I&#8217;d wondered about doing something like this for handling selections from a combo/drop-down.</p><p>Out of curiosity, why don&#8217;t you like this approach?  Would you prefer to cache the referenced object(s)?</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-11393</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Sun, 05 Apr 2009 17:13:20 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-11393</guid> <description>@Robertno idea actually... never used Castle ActiveRecord</description> <content:encoded><![CDATA[<p>@Robert</p><p>no idea actually&#8230; never used Castle ActiveRecord</p> ]]></content:encoded> </item> <item><title>By: robert</title><link>http://davybrion.com/blog/2009/04/assigning-foreign-keys-in-nhibernate/comment-page-1/#comment-11392</link> <dc:creator>robert</dc:creator> <pubDate>Sun, 05 Apr 2009 17:06:37 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1206#comment-11392</guid> <description>Nice!Any idea on how to accomplish this with Castle ActiveRecord?</description> <content:encoded><![CDATA[<p>Nice!</p><p>Any idea on how to accomplish this with Castle ActiveRecord?</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 2/13 queries in 0.006 seconds using disk: basic
Object Caching 453/454 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d18sni7re4ly7f.cloudfront.net

Served from: davybrion.com @ 2012-05-22 11:35:13 -->
