<?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: Part 5: Fixing the Broken Stuff</title>
	<atom:link href="http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/feed/" rel="self" type="application/rss+xml" />
	<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/</link>
	<description>I&#039;m just here for the code</description>
	<lastBuildDate>Mon, 06 Sep 2010 12:21:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dave Hanna</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-267</link>
		<dc:creator>Dave Hanna</dc:creator>
		<pubDate>Wed, 02 Sep 2009 20:02:39 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-267</guid>
		<description>Okay, if anybody cares, I&#039;ve found an  answer - not necessarily the best one.

If you define the collection as an Iesi.Collections.Generic.ISet, and initialize it with a Iesi.Collections.Generic.HashedSet, then the hbm will generate as a &gt;set&lt; tag, rather than a %gt;bag%lt;.

Only took me two days to figure that out.  I love FNH, but their documentation could be a little more substantial.  But it is open source!</description>
		<content:encoded><![CDATA[<p>Okay, if anybody cares, I&#8217;ve found an  answer &#8211; not necessarily the best one.</p>
<p>If you define the collection as an Iesi.Collections.Generic.ISet, and initialize it with a Iesi.Collections.Generic.HashedSet, then the hbm will generate as a &gt;set&lt; tag, rather than a %gt;bag%lt;.</p>
<p>Only took me two days to figure that out.  I love FNH, but their documentation could be a little more substantial.  But it is open source!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Hanna</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-246</link>
		<dc:creator>Dave Hanna</dc:creator>
		<pubDate>Tue, 01 Sep 2009 20:53:07 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-246</guid>
		<description>Yep, you&#039;re right.  I exported the mappings and looked at the HBM files. It&#039;s using the &quot;&quot; tag in the OneToMany mapping, whereas in the mappings we did by hand, you used &quot;.AsSet&quot;.

Your reasons for using sets make sense. I&#039;m trying to understand the Fluent convention stuff to figure out how to make &quot;AsSet&quot; the default.</description>
		<content:encoded><![CDATA[<p>Yep, you&#8217;re right.  I exported the mappings and looked at the HBM files. It&#8217;s using the &#8220;&#8221; tag in the OneToMany mapping, whereas in the mappings we did by hand, you used &#8220;.AsSet&#8221;.</p>
<p>Your reasons for using sets make sense. I&#8217;m trying to understand the Fluent convention stuff to figure out how to make &#8220;AsSet&#8221; the default.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-240</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Mon, 31 Aug 2009 21:53:22 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-240</guid>
		<description>@Dave - I&#039;m glad you&#039;re giving it a shot in a real world app, and more importantly, experimenting. This is exactly the feedback I was hoping this series would generate.

#1 - I couldn&#039;t say without seeing the mapping generated by FNH&#039;s automap. I suspect that it has automapped this collection as a list, not a set. If that&#039;s the case, I can&#039;t tell you how to change that behavior. When it comes to my DB and my model, I&#039;m a bit of a control freak, so I explicitly map everything. The FNH google group can provide better assistance.

#2 - We use sets for two reasons. First, the order of the sections is unimportant. Since, in a list, order is maintained (at least within the POCO), it can imply that order is important. More importantly, sets don&#039;t allow duplicates. It makes no sense to have a section associated with its parent course multiple times, and can lead to bugs.</description>
		<content:encoded><![CDATA[<p>@Dave &#8211; I&#8217;m glad you&#8217;re giving it a shot in a real world app, and more importantly, experimenting. This is exactly the feedback I was hoping this series would generate.</p>
<p>#1 &#8211; I couldn&#8217;t say without seeing the mapping generated by FNH&#8217;s automap. I suspect that it has automapped this collection as a list, not a set. If that&#8217;s the case, I can&#8217;t tell you how to change that behavior. When it comes to my DB and my model, I&#8217;m a bit of a control freak, so I explicitly map everything. The FNH google group can provide better assistance.</p>
<p>#2 &#8211; We use sets for two reasons. First, the order of the sections is unimportant. Since, in a list, order is maintained (at least within the POCO), it can imply that order is important. More importantly, sets don&#8217;t allow duplicates. It makes no sense to have a section associated with its parent course multiple times, and can lead to bugs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Hanna</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-237</link>
		<dc:creator>Dave Hanna</dc:creator>
		<pubDate>Mon, 31 Aug 2009 20:31:59 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-237</guid>
		<description>Jason, this on a different topic. I&#039;m following along in this series, and applying the principles to a project I&#039;m working on.  Except that I decided to try out  the FluentNHibernate.Automapping routines.

I have a &quot;subscriber&quot; class which is very simple, but contains a HasMany relationship to SubscriberContacts (e.g., email, cell phone, etc.) It is implemented just like Sections property in your Course object:
 
        private ICollection _subscriberContacts = new HashSet();
        public virtual ICollection SubscriberContacts { get { return _subscriberContacts; }
            protected set { _subscriberContacts = value; } }

However, when I get to the Session.Save(newSub), NHibernate is throwing an InvalidCast exception saying it can&#039;t cast a HashSet to a IList (which it can&#039;t - HashSet is an ICollection, but not an IList).

My question is two fold - why is NHibernate trying to cast it to an IList, and why did we implement the collection with a HashSet as opposed to a List?</description>
		<content:encoded><![CDATA[<p>Jason, this on a different topic. I&#8217;m following along in this series, and applying the principles to a project I&#8217;m working on.  Except that I decided to try out  the FluentNHibernate.Automapping routines.</p>
<p>I have a &#8220;subscriber&#8221; class which is very simple, but contains a HasMany relationship to SubscriberContacts (e.g., email, cell phone, etc.) It is implemented just like Sections property in your Course object:</p>
<p>        private ICollection _subscriberContacts = new HashSet();<br />
        public virtual ICollection SubscriberContacts { get { return _subscriberContacts; }<br />
            protected set { _subscriberContacts = value; } }</p>
<p>However, when I get to the Session.Save(newSub), NHibernate is throwing an InvalidCast exception saying it can&#8217;t cast a HashSet to a IList (which it can&#8217;t &#8211; HashSet is an ICollection, but not an IList).</p>
<p>My question is two fold &#8211; why is NHibernate trying to cast it to an IList, and why did we implement the collection with a HashSet as opposed to a List?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tuna Toksoz</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-154</link>
		<dc:creator>Tuna Toksoz</dc:creator>
		<pubDate>Wed, 26 Aug 2009 21:04:01 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-154</guid>
		<description>Datasets are hard to deal with, you can&#039;t fine tune their behavior. They are bloated and heavy, on the other hand, in NH, you have Plain Old Csharp Objects, which represents your &quot;domain&quot; as pposed to your database.</description>
		<content:encoded><![CDATA[<p>Datasets are hard to deal with, you can&#8217;t fine tune their behavior. They are bloated and heavy, on the other hand, in NH, you have Plain Old Csharp Objects, which represents your &#8220;domain&#8221; as pposed to your database.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-153</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 26 Aug 2009 20:59:20 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-153</guid>
		<description>@Dave - I apologize for the unposted updates between #4 and 5. They were necessary to illustrate some points I wanted to make in #5. I&#039;ll try to go back and document those changes. 

NHibernate is light-years ahead of the strongly-typed dataset approach. I know. I&#039;ve been converted. At best, datasets will give you a bunch of DTOs to use in your own custom DAL with connections, transactions and DataAdapters flying all over. NH lets you just build your model and use it with an intelligent DAL already baked in. 

Ayende&#039;s blog is following a series by Davey Brion about building your own DAL and comparing that the NH features you get for free. It&#039;s worth a read.

http://ayende.com/Blog/archive/2009/08/24/a-guide-into-orm-implementation-challenges-reasoning.aspx

http://davybrion.com/blog/2009/08/build-your-own-data-access-layer-series/</description>
		<content:encoded><![CDATA[<p>@Dave &#8211; I apologize for the unposted updates between #4 and 5. They were necessary to illustrate some points I wanted to make in #5. I&#8217;ll try to go back and document those changes. </p>
<p>NHibernate is light-years ahead of the strongly-typed dataset approach. I know. I&#8217;ve been converted. At best, datasets will give you a bunch of DTOs to use in your own custom DAL with connections, transactions and DataAdapters flying all over. NH lets you just build your model and use it with an intelligent DAL already baked in. </p>
<p>Ayende&#8217;s blog is following a series by Davey Brion about building your own DAL and comparing that the NH features you get for free. It&#8217;s worth a read.</p>
<p><a href="http://ayende.com/Blog/archive/2009/08/24/a-guide-into-orm-implementation-challenges-reasoning.aspx" rel="nofollow">http://ayende.com/Blog/archive/2009/08/24/a-guide-into-orm-implementation-challenges-reasoning.aspx</a></p>
<p><a href="http://davybrion.com/blog/2009/08/build-your-own-data-access-layer-series/" rel="nofollow">http://davybrion.com/blog/2009/08/build-your-own-data-access-layer-series/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Hanna</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-150</link>
		<dc:creator>Dave Hanna</dc:creator>
		<pubDate>Wed, 26 Aug 2009 01:14:03 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-150</guid>
		<description>Well, I actually worked through that. I moved the Session.Save(Section1) and Section2 AFTER the Session.Save(Course), and the error went away (I still don&#039;t understand that), and then I was able to work through the remainder of the errors just as you described.

I do have a question though.  Back in Part 3, in the paragraph &quot;8 Hours or 8 Minutes&quot;, you implied that this approach is much easier than setting up your database.  I&#039;ve done a few applications using both MySql and MSSQL with Visual Studio and DataSets, in which I just go into the server explorer, define the tables, click Add New Item -&gt; DataSet, and drag the tables  from the server explorer onto the design surface, and presto, I have all my mappings.  That seems an order of magnitude easier than this. What are the advantages to the NHibernate approach, even with Fluent mappings?</description>
		<content:encoded><![CDATA[<p>Well, I actually worked through that. I moved the Session.Save(Section1) and Section2 AFTER the Session.Save(Course), and the error went away (I still don&#8217;t understand that), and then I was able to work through the remainder of the errors just as you described.</p>
<p>I do have a question though.  Back in Part 3, in the paragraph &#8220;8 Hours or 8 Minutes&#8221;, you implied that this approach is much easier than setting up your database.  I&#8217;ve done a few applications using both MySql and MSSQL with Visual Studio and DataSets, in which I just go into the server explorer, define the tables, click Add New Item -&gt; DataSet, and drag the tables  from the server explorer onto the design surface, and presto, I have all my mappings.  That seems an order of magnitude easier than this. What are the advantages to the NHibernate approach, even with Fluent mappings?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Hanna</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-149</link>
		<dc:creator>Dave Hanna</dc:creator>
		<pubDate>Wed, 26 Aug 2009 00:30:31 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-149</guid>
		<description>I&#039;m really having difficulty following you in the analysis of the problems, because the code you have in the explanations doesn&#039;t match the code you gave us in part 4, and the explanation of the changes are not completely clear.  When I put in what I think are the changes you&#039;re suggesting, I get entirely different errors than you do, and they don&#039;t make sense.

Specifically, on Problem #1, if I add Session.Save(Section1) and Session.Save(Section2) before the Session.Save(Course), then I&#039;m getting a different exception from NHibernate saying &quot;not-null property references a null or transient valueNStackExample.Section.Course&quot; at the point I do the Session.Save(Section1).  So it appears that you can&#039;t save the Course until  you have saved  the Section, and you can&#039;t save the Section until you have saved the Course!  How do you solve that?</description>
		<content:encoded><![CDATA[<p>I&#8217;m really having difficulty following you in the analysis of the problems, because the code you have in the explanations doesn&#8217;t match the code you gave us in part 4, and the explanation of the changes are not completely clear.  When I put in what I think are the changes you&#8217;re suggesting, I get entirely different errors than you do, and they don&#8217;t make sense.</p>
<p>Specifically, on Problem #1, if I add Session.Save(Section1) and Session.Save(Section2) before the Session.Save(Course), then I&#8217;m getting a different exception from NHibernate saying &#8220;not-null property references a null or transient valueNStackExample.Section.Course&#8221; at the point I do the Session.Save(Section1).  So it appears that you can&#8217;t save the Course until  you have saved  the Section, and you can&#8217;t save the Section until you have saved the Course!  How do you solve that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: t800t8</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-141</link>
		<dc:creator>t800t8</dc:creator>
		<pubDate>Mon, 24 Aug 2009 15:27:18 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-141</guid>
		<description>I added System.Data.SQLite.dll in ManagedOnly folder to project and the problem was fixed</description>
		<content:encoded><![CDATA[<p>I added System.Data.SQLite.dll in ManagedOnly folder to project and the problem was fixed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: t800t8</title>
		<link>http://jasondentler.com/blog/2009/08/part-5-fixing-the-broken-stuff/comment-page-1/#comment-140</link>
		<dc:creator>t800t8</dc:creator>
		<pubDate>Mon, 24 Aug 2009 15:05:57 +0000</pubDate>
		<guid isPermaLink="false">http://jasondentler.com/blog/?p=315#comment-140</guid>
		<description>I tried to run the tests but I have &quot;System.BadImageFormatException: Could not load file or assembly &#039;System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#039; or one of its dependencies. An attempt was made to load a program with an incorrect format.&quot;

I tried to add 32-bit and 64-bit of System.Data.SQLite but it didn&#039;t help. 

Do you have any idea about this problem? Thanks</description>
		<content:encoded><![CDATA[<p>I tried to run the tests but I have &#8220;System.BadImageFormatException: Could not load file or assembly &#8216;System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#8242; or one of its dependencies. An attempt was made to load a program with an incorrect format.&#8221;</p>
<p>I tried to add 32-bit and 64-bit of System.Data.SQLite but it didn&#8217;t help. </p>
<p>Do you have any idea about this problem? Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
