<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>TDD developer</title>
	<atom:link href="http://testdrivendevelopment.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://testdrivendevelopment.wordpress.com</link>
	<description>Diary of an agile developer</description>
	<lastBuildDate>Mon, 13 Dec 2010 10:17:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='testdrivendevelopment.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>TDD developer</title>
		<link>http://testdrivendevelopment.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://testdrivendevelopment.wordpress.com/osd.xml" title="TDD developer" />
	<atom:link rel='hub' href='http://testdrivendevelopment.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ConfORM: understand core pieces</title>
		<link>http://testdrivendevelopment.wordpress.com/2010/09/06/conform-understand-core-pieces/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2010/09/06/conform-understand-core-pieces/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 23:09:25 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[conform]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">https://testdrivendevelopment.wordpress.com/2010/09/06/conform-understand-core-pieces/</guid>
		<description><![CDATA[If you read the post ConfORM Gettins started you already know that NHibernate mapping task could be very easy with ConfORM. But unfortunately real project are a little bit more complicated that the example I shown in my first post about ConfORM so we need to understand how we can squeeze the tool to get [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=132&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you read the post <a href="http://testdrivendevelopment.wordpress.com/2010/09/02/conform-getting-started/">ConfORM Gettins started</a> you already know that <a href="http://nhforge.org">NHibernate</a> mapping task could be very easy with <a href="http://code.google.com/p/codeconform/">ConfORM</a>. But unfortunately real project are a little bit more complicated that the example I shown in <a href="testdrivendevelopment.wordpress.com/2010/09/02/conform-getting-started/">my first post</a> about <a href="http://code.google.com/p/codeconform/">ConfORM</a> so we need to understand how we can squeeze the tool to get the work done also when things get complicated.</p>
<p>The key to success is to understand which are the many configuration points of <a href="http://code.google.com/p/codeconform/">ConfORM</a>: <a href="http://codeconform.googlecode.com/hg/ConfOrm/ConfOrm/IDomainInspector.cs">IDomainInspector</a> and <a href="http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm/NH/Mapper.cs">Mapper</a>. This two pieces can be described as the head and the tail of the mapping process.<br />
<a href="http://codeconform.googlecode.com/hg/ConfOrm/ConfOrm/IDomainInspector.cs">IDomainInspector</a> is the entry point and also the mapping driver. This object is used to describe our domain model and currently there is only one concrete implementation of it: <a href="http://codeconform.googlecode.com/hg/ConfOrm/ConfOrm/ObjectRelationalMapper.cs">ObjectRelationalMapper</a>. <a href="http://codeconform.googlecode.com/hg/ConfOrm/ConfOrm/ObjectRelationalMapper.cs">ObjectRelationalMapper</a> class use ORM terminology to descride domain: TablePerClass, TablePerConcreteClass, ManyToMany, ManyToOne, OneToOne, Set, Bag, List, Poid, Component are just some of the methods you’ll find in it (they are also grouped inside the IObjectRelationalMapper interface but this is an implementation details). Another important thing to consider is that <a href="http://codeconform.googlecode.com/hg/ConfOrm/ConfOrm/IDomainInspector.cs">IDomainInspector</a> is just an interface and this means that if don’t like the current implementation (ObjectRelationalMapper) you can write your own and use with <a href="http://code.google.com/p/codeconform/">ConfORM</a>. For example you could create a DomainDrivenDesignMappper that has method like RootAggregate, ValueObjec an so on.<br />
The other important object is the the <a href="http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm/NH/Mapper.cs">Mapper</a>.</p>
<pre class="csharpcode"><span class="kwrd">namespace</span> ConfOrm.NH
{
    <span class="kwrd">public</span> <span class="kwrd">class</span> Mapper
    {
        <span class="kwrd">public</span> Mapper(IDomainInspector domainInspector);
        <span class="kwrd">public</span> Mapper(IDomainInspector domainInspector, ICustomizersHolder customizerHolder);
        <span class="kwrd">public</span> Mapper(IDomainInspector domainInspector, IPatternsAppliersHolder patternsAppliers);

        <span class="kwrd">public</span> Mapper(IDomainInspector domainInspector, ICustomizersHolder customizerHolder,
                      IPatternsAppliersHolder patternsAppliers, ICandidatePersistentMembersProvider membersProvider);

        <span class="kwrd">public</span> IPatternsAppliersHolder PatternsAppliers { get; }

        <span class="kwrd">public</span> <span class="kwrd">void</span> Class&lt;TRootEntity&gt;(Action&lt;IClassMapper&lt;TRootEntity&gt;&gt; customizeAction) <span class="kwrd">where</span> TRootEntity : <span class="kwrd">class</span>;
        <span class="kwrd">public</span> <span class="kwrd">void</span> Subclass&lt;TEntity&gt;(Action&lt;ISubclassMapper&lt;TEntity&gt;&gt; customizeAction) <span class="kwrd">where</span> TEntity : <span class="kwrd">class</span>;

        <span class="kwrd">public</span> <span class="kwrd">void</span> JoinedSubclass&lt;TEntity&gt;(Action&lt;IJoinedSubclassMapper&lt;TEntity&gt;&gt; customizeAction)
            <span class="kwrd">where</span> TEntity : <span class="kwrd">class</span>;

        <span class="kwrd">public</span> <span class="kwrd">void</span> UnionSubclass&lt;TEntity&gt;(Action&lt;IUnionSubclassMapper&lt;TEntity&gt;&gt; customizeAction) <span class="kwrd">where</span> TEntity : <span class="kwrd">class</span>;
        <span class="kwrd">public</span> <span class="kwrd">void</span> Component&lt;TComponent&gt;(Action&lt;IComponentMapper&lt;TComponent&gt;&gt; customizeAction) <span class="kwrd">where</span> TComponent : <span class="kwrd">class</span>;

        <span class="kwrd">public</span> <span class="kwrd">void</span> Customize&lt;TPersistent&gt;(Action&lt;IPersistentClassCustomizer&lt;TPersistent&gt;&gt; customizeAction)
            <span class="kwrd">where</span> TPersistent : <span class="kwrd">class</span>;

        <span class="kwrd">public</span> <span class="kwrd">void</span> AddPoidPattern(Predicate&lt;MemberInfo&gt; matcher, Action&lt;MemberInfo, IIdMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddPropertyPattern(Predicate&lt;MemberInfo&gt; matcher, Action&lt;IPropertyMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddPropertyPattern(Predicate&lt;MemberInfo&gt; matcher, Action&lt;MemberInfo, IPropertyMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddCollectionPattern(Predicate&lt;MemberInfo&gt; matcher, Action&lt;ICollectionPropertiesMapper&gt; applier);

        <span class="kwrd">public</span> <span class="kwrd">void</span> AddCollectionPattern(Predicate&lt;MemberInfo&gt; matcher,
                                         Action&lt;MemberInfo, ICollectionPropertiesMapper&gt; applier);

        <span class="kwrd">public</span> <span class="kwrd">void</span> AddManyToOnePattern(Predicate&lt;MemberInfo&gt; matcher, Action&lt;IManyToOneMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddManyToOnePattern(Predicate&lt;MemberInfo&gt; matcher, Action&lt;MemberInfo, IManyToOneMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddRootClassPattern(Predicate&lt;Type&gt; matcher, Action&lt;Type, IClassAttributesMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddSubclassPattern(Predicate&lt;Type&gt; matcher, Action&lt;Type, ISubclassAttributesMapper&gt; applier);

        <span class="kwrd">public</span> <span class="kwrd">void</span> AddJoinedSubclassPattern(Predicate&lt;Type&gt; matcher,
                                             Action&lt;Type, IJoinedSubclassAttributesMapper&gt; applier);

        <span class="kwrd">public</span> <span class="kwrd">void</span> AddUnionSubclassPattern(Predicate&lt;Type&gt; matcher,
                                            Action&lt;Type, IUnionSubclassAttributesMapper&gt; applier);

        <span class="kwrd">public</span> <span class="kwrd">void</span> AddRootClassPattern(Predicate&lt;Type&gt; matcher, Action&lt;IClassAttributesMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddSubclassPattern(Predicate&lt;Type&gt; matcher, Action&lt;ISubclassAttributesMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddJoinedSubclassPattern(Predicate&lt;Type&gt; matcher, Action&lt;IJoinedSubclassAttributesMapper&gt; applier);
        <span class="kwrd">public</span> <span class="kwrd">void</span> AddUnionSubclassPattern(Predicate&lt;Type&gt; matcher, Action&lt;IUnionSubclassAttributesMapper&gt; applier);
        <span class="kwrd">public</span> HbmMapping CompileMappingFor(IEnumerable&lt;Type&gt; types);

        <span class="kwrd">protected</span> <span class="kwrd">virtual</span> Mapper.ICollectionElementRelationMapper DetermineCollectionElementRelationType(
            MemberInfo property, PropertyPath propertyPath, Type collectionElementType);

        <span class="kwrd">public</span> IEnumerable&lt;HbmMapping&gt; CompileMappingForEach(IEnumerable&lt;Type&gt; types);
        <span class="kwrd">public</span> <span class="kwrd">void</span> TypeDef&lt;TComplex, TUserType&gt;() <span class="kwrd">where</span> TUserType : IUserType;

        <span class="preproc">#region</span> Nested type: ICollectionElementRelationMapper

        <span class="kwrd">protected</span> <span class="kwrd">interface</span> ICollectionElementRelationMapper
        {
            <span class="kwrd">void</span> Map(ICollectionElementRelation relation);
            <span class="kwrd">void</span> MapCollectionProperties(ICollectionPropertiesMapper mapped);
        }

        <span class="preproc">#endregion</span>

        <span class="preproc">#region</span> Nested type: IMapKeyRelationMapper

        <span class="kwrd">protected</span> <span class="kwrd">interface</span> IMapKeyRelationMapper
        {
            <span class="kwrd">void</span> Map(IMapKeyRelation relation);
        }

        <span class="preproc">#endregion</span>
    }
}</pre>
<p>If you look carefully at the namespace of this class you’ll notice the is “ConfOrm.NH” and if you analize the contructors you’ll understand that the <a href="http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm/NH/Mapper.cs">ConfOrm.NH.Mapper</a> class takes always an <a href="http://codeconform.googlecode.com/hg/ConfOrm/ConfOrm/IDomainInspector.cs">IDomainInspector</a> and than analize and compile it to a HbmMapping instance via CompileMappingFor or CompileMappingForEach methods (read this <a href="http://testdrivendevelopment.wordpress.com/2010/09/02/conform-getting-started/">post</a> if you need a real sample of this usage)</p>
<p>With the methods on <a href="http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm/NH/Mapper.cs">Mapper</a> you can customize its behavior. For example you can customize the table name mapped to a class with this line of code:</p>
<pre class="csharpcode">mapper.Class&lt;Answer&gt;(cm =&gt; cm.Table(<span class="str">"a_dummy_table_name"</span>));</pre>
<p>or set the Length of the properties using this expression:</p>
<pre class="csharpcode">mapper.Customize&lt;Name&gt;(name =&gt;
{
             name.Property(np =&gt; np.First, pm =&gt; pm.Length(20));
             name.Property(np =&gt; np.Last, pm =&gt; pm.Length(35));
});</pre>
<p>This two tasks (table names and property length) aren’t detail of the domain model. They are questions related to the database that’s the reason why the are handled by the <a href="http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm/NH/Mapper.cs">Mapper</a> class and not by the <a href="http://codeconform.googlecode.com/hg/ConfOrm/ConfOrm/IDomainInspector.cs">IDomainInspector</a>.</p>
<p>Last but not least in the future someone could be interested in using <a href="http://code.google.com/p/codeconform/">ConfORM</a> with another ORM. All you need to do is to write your own Mapper.</p>
<p>Are you <a href="http://code.google.com/p/codeconform/">ConfORM</a> ?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=132&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2010/09/06/conform-understand-core-pieces/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>
	</item>
		<item>
		<title>ConfORM &#8211; Output XML mappings</title>
		<link>http://testdrivendevelopment.wordpress.com/2010/09/05/conform-output-xml-mappings/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2010/09/05/conform-output-xml-mappings/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 09:46:22 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[conform]]></category>

		<guid isPermaLink="false">https://testdrivendevelopment.wordpress.com/?p=115</guid>
		<description><![CDATA[As described in this post ConfORM doesn&#8217;t desirialize xml files into C# objects as many others tools do therefore no xml is produced by default by ConfORM. But many times, for NHibernate users, watching an hbm.xml files is just the simplest way to detect how NHibernate is configured. This the reason why the leatest bits of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=115&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As described in this <a href="http://fabiomaulo.blogspot.com/2010/03/nhibernate-mappings-path.html">post</a> <a href="http://http://code.google.com/p/codeconform/">ConfORM</a> doesn&#8217;t desirialize xml files into C# objects as many others tools do therefore no xml is produced by default by <a href="http://http://code.google.com/p/codeconform/">ConfORM</a>. But many times, for <a href="http://nhforge.org">NHibernate</a> users, watching an hbm.xml files is just the simplest way to detect how <a href="http://nhforge.org">NHibernate</a> is configured. This the reason why the leatest bits of <a href="http://http://code.google.com/p/codeconform/">ConfORM</a> contains a class callled NHibernateMappingsExtensions (inside ConfOrm.UsageExamples project) that is just a util extensions to use in your tests or where you need to see the XML mappings. This class doesn&#8217;t do anything special: it serializes instances of HbmMapping objects, that is the <a href="http://nhforge.org">NHibernate</a>&#8216;s object holding the mapping information, into xml. The HbmMapping instance is created by the <a href="http://http://code.google.com/p/codeconform/">ConfORM</a> Mapper class which a class that any <a href="http://http://code.google.com/p/codeconform/">ConfORM</a>&#8216;s users should know very well since it&#8217;s one the key pieces of the tool (I&#8217;ll blog about it soon).</p>
<p>NHibernateMappingsExtensions usage it very simple. Copy &amp; paste this class inside your test project and write down a test that set up <a href="http://http://code.google.com/p/codeconform/">ConfORM</a> correctly</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2010/09/capture3.jpg"><img class="alignnone size-full wp-image-123" title="Capture" src="http://testdrivendevelopment.files.wordpress.com/2010/09/capture3.jpg?w=602&#038;h=173" alt="" width="602" height="173" /></a></p>
<p>and finally call the method AsString() if you want to see all the xml in the output console like this</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2010/09/capture1.jpg"><img class="alignnone size-full wp-image-119" title="Capture" src="http://testdrivendevelopment.files.wordpress.com/2010/09/capture1.jpg?w=687&#038;h=502" alt="" width="687" height="502" /></a></p>
<p>or call the method WriteAllXmlMapping() if you want a single .hbm.xml file for each domain object on the disk</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2010/09/capture2.jpg"><img class="alignnone size-full wp-image-121" title="Capture" src="http://testdrivendevelopment.files.wordpress.com/2010/09/capture2.jpg?w=465&#038;h=200" alt="" width="465" height="200" /></a></p>
<p>You could find more samples of this two methods in the <a href="http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm.UsageExamples/">ConfOrm.UsageExamples project</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=115&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2010/09/05/conform-output-xml-mappings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2010/09/capture3.jpg" medium="image">
			<media:title type="html">Capture</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2010/09/capture1.jpg" medium="image">
			<media:title type="html">Capture</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2010/09/capture2.jpg" medium="image">
			<media:title type="html">Capture</media:title>
		</media:content>
	</item>
		<item>
		<title>ConfORM- Getting started</title>
		<link>http://testdrivendevelopment.wordpress.com/2010/09/02/conform-getting-started/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2010/09/02/conform-getting-started/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 21:46:13 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[conform]]></category>

		<guid isPermaLink="false">https://testdrivendevelopment.wordpress.com/?p=108</guid>
		<description><![CDATA[ConfORM is a just another option to create the mapping for NHibernate. Out-of-the-box NHibernate mapping&#8217;s can be created only with XML mapping files (*.hbb.xml files). ConfORM uses code instead of XML. If you are thinking that there is already at least one tool that follow this approach you should read this post to understand which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=108&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/codeconform/">ConfORM</a> is a just another option to create the mapping for NHibernate. Out-of-the-box NHibernate mapping&#8217;s can be created only with XML mapping files (*.hbb.xml files). <a href="http://code.google.com/p/codeconform/">ConfORM</a> uses code instead of XML. If you are thinking that there is already at least one tool that follow this approach you should read this <a href="http://fabiomaulo.blogspot.com/2010/03/nhibernate-mappings-path.html">post</a> to understand which are the differences between the other tools and <a href="http://code.google.com/p/codeconform/">ConfORM</a>.     <br />After this brief introduction I want to show you a little example of <a href="http://code.google.com/p/codeconform/">ConfORM</a>’s usage to demonstrate how easy could be life with this tool.&#160;&#160; <br />Here below I posted a screenshot of my domain model. As you can see there is nothing special here: some <a href="http://nhforge.org/doc/nh/en/index.html#collections-mapping">Collections</a> and some <a href="http://nhforge.org/doc/nh/en/index.html#mapping-declaration-manytoone">ManyToOne</a> relationships. There is also a read-only property: Element.HasGroupedAnswer (sorry you can’t see it in the screenshot below) .     </p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2010/09/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2010/09/image_thumb.png?w=619&#038;h=480" width="619" height="480" /></a></p>
<p>The very first step is to create a valid configuration object for NHibernate. Using NHibernate.Cfg.Loquacious feature from NHibernate version 3 this can be done with this lines of code. </p>
<pre class="csharpcode">            Configuration configure = <span class="kwrd">new</span> Configuration();
            configure.SessionFactoryName(<span class="str">&quot;Demo&quot;</span>);
            configure.Proxy(p =&gt;
            {
                p.Validation = <span class="kwrd">false</span>;
                p.ProxyFactoryFactory&lt;ProxyFactoryFactory&gt;();
            });
            configure.Properties[<span class="str">&quot;current_session_context_class&quot;</span>] = _context;
            configure.DataBaseIntegration(db =&gt;
            {
                db.Dialect&lt;MsSql2008Dialect&gt;();
                db.Driver&lt;SqlClientDriver&gt;();
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                db.IsolationLevel = IsolationLevel.ReadCommitted;
                db.LogFormatedSql = LogSqlInConsole;
                db.LogSqlInConsole = LogSqlInConsole;
                db.ConnectionString = <span class="str">&quot;yuor connection string goes here&quot;</span>;
                db.Timeout = 10;
                db.HqlToSqlSubstitutions = <span class="str">&quot;true 1, false 0, yes 'Y', no 'N'&quot;</span>;
            });</pre>
<pre class="csharpcode">&#160;</pre>
<p>Once configuration object is ready we must setup mapping for our domain. Now it’s time to use ConfORM. I decided to wrap all mapping stuff inside the class shown below.</p>
<pre class="csharpcode">    <span class="kwrd">public</span> <span class="kwrd">class</span> ConfOrmDomainMapper
    {
        <span class="kwrd">public</span> ConfOrmDomainMapper()
        {
            orm = <span class="kwrd">new</span> ObjectRelationalMapper();
            orm.Patterns.PoidStrategies.Add(<span class="kwrd">new</span> NativePoidPattern());
            var patternsAppliers = <span class="kwrd">new</span> CoolPatternsAppliersHolder(orm);

            mapper = <span class="kwrd">new</span> Mapper(orm, patternsAppliers);

            DefineDomain();
            DefineMapping();
        }

        <span class="kwrd">private</span> <span class="kwrd">void</span> DefineMapping()
        {
        }

        <span class="kwrd">private</span> <span class="kwrd">void</span> DefineDomain()
        {
            orm.TablePerClass(GetTypes());
        }

        <span class="kwrd">public</span> HbmMapping Mapping
        {
            get { <span class="kwrd">return</span> mapper.CompileMappingFor(GetTypes()); }
        }

        IEnumerable&lt;Type&gt; GetTypes()
        {
            var type = <span class="kwrd">typeof</span>(BaseEntity);
            <span class="kwrd">return</span> type.Assembly.GetTypes().Where(t =&gt; t.BaseType == type);
        }
        <span class="kwrd">private</span> <span class="kwrd">readonly</span> ObjectRelationalMapper orm;
        <span class="kwrd">private</span> <span class="kwrd">readonly</span> Mapper mapper;
    }</pre>
<p>Since all the classes in my domain model inherit from a common class called BaseEntity I can use reflection to get all types with a single line of code. This is not mandatory for ConfORM but as you can the result is very nice. In this simple sample I don’t need to customize the mapper but if you need to do you can use the Mapper class instance. Now all the mapping is already done. Since I used CoolPatternsAppliersHolder <a href="http://code.google.com/p/codeconform/">ConfORM</a> already create a complete mapping to start working with NHibernate (I’ll blog some details about it in the future)</p>
<p>To finish I need to join ConfORM mappings and NHibernate configuration. This task is done with this few lines of code:</p>
<pre class="csharpcode">ConfOrmDomainMapper domainMapper = <span class="kwrd">new</span> ConfOrmDomainMapper();</pre>
<pre class="csharpcode">configure.AddDeserializedMapping(domainMapper.Mapping, <span class="str">&quot;MyAppDomain&quot;</span>);</pre>
<p>After this I’m ready to create a SessionFactory with</p>
<pre class="csharpcode">configure.BuildSessionFactory();</pre>
<p>and start using NHibernate a usual. </p>
<p>This was just the beginning. I hope to find some more time to write again about <a href="http://code.google.com/p/codeconform/">ConfORM</a>. </p>
<p>I want also thank <a href="http://fabiomaulo.blogspot.com/">Fabio Maulo</a> for sharing with community this another piece of great code!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=108&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2010/09/02/conform-getting-started/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2010/09/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Sql Azure first contact</title>
		<link>http://testdrivendevelopment.wordpress.com/2009/10/28/sql-azure-first-contact/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2009/10/28/sql-azure-first-contact/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 22:06:05 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[aspnetmvc]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[sqlazure]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2009/10/28/sql-azure-first-contact/</guid>
		<description><![CDATA[Tonight I’m starting a new project. Porting to the cloud a real application running “on premises”. The first step of this migration is the database. For the moment I want just to recreate the database schema. The data migration will be done in the future but since I hope the database schema will be the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=105&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tonight I’m starting a new project. Porting to the cloud a real application running “on premises”.</p>
<p>The first step of this migration is the database. For the moment I want just to recreate the database schema. The data migration will be done in the future but since I hope the database schema will be the same I believe this step will be an easy task.</p>
<p>I have already setup my SqlAzure credential (there are many posts about it). If you want to connect using SSMS (SQL Server Managment Studio) this are the step you need to follow:</p>
<ol>
<li>Cancel the first connection dialog that pops up when you open SSMS.</li>
<li>Click on the New Query button from the toolbar</li>
<li>Enter your server name: eg. xxxyyyzzz.database.windows.net</li>
<li>Enter your Login: <a href="mailto:username@xxxyyyzzz">username@xxxyyyzzz</a></li>
<li>Hit connect.</li>
</ol>
<p>This is my login prompt:</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2009/10/image.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb.png?w=304&#038;h=229" width="304" height="229" /></a> </p>
</p>
<p>If you get this error: “Invalid object name &#8216;sys.configurations&#8217;” it’s because you didn’t cancel the first logon prompt. </p>
<p>Once you logged on you are ready to go. In my case I have 2 scripts: one for database creation and one for the creation of the database’s objects (tables &amp; indexes). </p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2009/10/image1.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb1.png?w=304&#038;h=146" width="304" height="146" /></a> </p>
<p>The first it’s very very simple. Just the common CREATE DATABASE statement in order to create the db. No problem with that.</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2009/10/image2.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb2.png?w=404&#038;h=129" width="404" height="129" /></a> </p>
<p>Now my database is up &amp; running. I need a new connection to run the second script. It this connection I must set the database name in the options as shown below:</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2009/10/image3.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb3.png?w=304&#038;h=140" width="304" height="140" /></a> </p>
<p>Unfortunately with the second I get some errors at the first run cause I’m using some SqlServer features that are not available on SqlAzure. Using the “Parse” button several times I can detect which features are not supported and than correct my script.</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2009/10/image4.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb4.png?w=304&#038;h=126" width="304" height="126" /></a> </p>
</p>
<p>At the end my script pass and my database is ready to use.</p>
<p>In the next post I’ll try to migrate the web application (which is built with ASP.NET MVC V1)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=105&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2009/10/28/sql-azure-first-contact/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2009/10/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>IronRuby</title>
		<link>http://testdrivendevelopment.wordpress.com/2009/07/26/ironruby/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2009/07/26/ironruby/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 12:35:06 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2009/07/26/ironruby/</guid>
		<description><![CDATA[Today I watched this realy interesting presentation about IronRuby. Now that the implementation is near the version 0.9 I believe it’s time to start using IronRuby in a production environment. First of all I’ll use it for testing (RSpec) and for developing web application (Rails and IronRubyMVC) If you have time don’t miss it! Iron [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=92&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I watched this realy interesting presentation about <a href="http://ironruby.net/" target="_blank">IronRuby</a>. Now that the implementation is near the version 0.9 I believe it’s time to start using <a href="http://ironruby.net/" target="_blank">IronRuby</a> in a production environment. First of all I’ll use it for testing (<a href="http://rspec.info/" target="_blank">RSpec</a>) and for developing web application (<a href="http://rubyonrails.org/" target="_blank">Rails</a> and <a href="http://github.com/jschementi/ironrubymvc/tree/master" target="_blank">IronRubyMVC</a>)</p>
<p>If you have time don’t miss it!</p>
</p>
<p><a href="http://vimeo.com/5660902">Iron Ruby (Ben Hall)</a> from <a href="http://vimeo.com/vistasquad">Vista Squad</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=92&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2009/07/26/ironruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Web Toolkit (GWT) on Ubuntu Desktop 9.04</title>
		<link>http://testdrivendevelopment.wordpress.com/2009/06/28/google-web-toolkit-gwt-on-ubuntu-desktop-9-04/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2009/06/28/google-web-toolkit-gwt-on-ubuntu-desktop-9-04/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 12:20:01 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2009/06/28/google-web-toolkit-gwt-on-ubuntu-desktop-9-04/</guid>
		<description><![CDATA[After watching a Google Wave video presentation my interest in the Google Web Toolkit (GWT) grown so I decided to create Virtual Machine with all the stuff I need to play with GWT. I’m using a VMWare virtual machine with Ubuntu Desktop 9.04. Im order to setup the development environment I found this great blog [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=91&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After watching a <a href="http://wave.google.com/" target="_blank">Google Wave</a> video presentation my interest in the Google Web Toolkit (GWT) grown so I decided to create Virtual Machine with all the stuff I need to play with GWT. I’m using a VMWare virtual machine with Ubuntu Desktop 9.04. </p>
<p>Im order to setup the development environment I found this great blog post with detailed informations on <a href="http://www.evejam.co.uk/node/132" target="_blank">how to set up Glassfish, Eclipse, Google Web toolkit (GWT), Development Environment on Ubuntu Desktop 9.04</a>.</p>
<p>I follow the instruction step by step. I’m not a Linux geek but everything was quite easy. Here below you can see my first application build with GWT.</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2009/06/capture1.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="Capture" border="0" alt="Capture" src="http://testdrivendevelopment.files.wordpress.com/2009/06/capture_thumb1.jpg?w=644&#038;h=484" width="644" height="484" /></a> </p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c4918d6c-fab6-48ec-bf11-1cb5b0fe4b57" class="wlWriterEditableSmartContent">Technorati Tag: <a href="http://technorati.com/tags/Google+Web+Toolkit" rel="tag">Google Web Toolkit</a>,<a href="http://technorati.com/tags/GWT" rel="tag">GWT</a>,<a href="http://technorati.com/tags/Ubuntu" rel="tag">Ubuntu</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=91&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2009/06/28/google-web-toolkit-gwt-on-ubuntu-desktop-9-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2009/06/capture_thumb1.jpg" medium="image">
			<media:title type="html">Capture</media:title>
		</media:content>
	</item>
		<item>
		<title>Moonlight on Ubuntu 9 with Firefox</title>
		<link>http://testdrivendevelopment.wordpress.com/2009/06/25/moonlight-on-ubuntu-9-with-firefox/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2009/06/25/moonlight-on-ubuntu-9-with-firefox/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 19:14:32 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2009/06/25/moonlight-on-ubuntu-9-with-firefox/</guid>
		<description><![CDATA[Just few mouse clicks and it works like a charm. Here below you can see the site of the italian national television build with silverlight 2.0 Technorati Tag: ubuntu,moonlight,mono<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=88&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just few mouse clicks and it works like a charm.</p>
<p>Here below you can see the site of the italian national television build with silverlight 2.0</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2009/06/capture.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="Capture" border="0" alt="Capture" src="http://testdrivendevelopment.files.wordpress.com/2009/06/capture_thumb.jpg?w=623&#038;h=484" width="623" height="484" /></a> </p>
</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6428516b-ff6b-47ef-9191-cbe6eecbed90" class="wlWriterEditableSmartContent">Technorati Tag: <a href="http://technorati.com/tags/ubuntu" rel="tag">ubuntu</a>,<a href="http://technorati.com/tags/moonlight" rel="tag">moonlight</a>,<a href="http://technorati.com/tags/mono" rel="tag">mono</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=88&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2009/06/25/moonlight-on-ubuntu-9-with-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2009/06/capture_thumb.jpg" medium="image">
			<media:title type="html">Capture</media:title>
		</media:content>
	</item>
		<item>
		<title>NHibernate 2.1.0 beta 2</title>
		<link>http://testdrivendevelopment.wordpress.com/2009/06/21/nhibernate-2-1-0-beta-2/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2009/06/21/nhibernate-2-1-0-beta-2/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 17:15:56 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[NH2.1]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2009/06/21/nhibernate-2-1-0-beta-2/</guid>
		<description><![CDATA[Today NHibernate team released version 2.1.0 beta 2 This version contains a fix for bug that cause some problem with MS Sql server execution plans (more details here). Be carefull if you use an HQL query cause the actual parser is not still able to use the correct parameter type. I hope also this issue [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=85&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today NHibernate team released version 2.1.0 beta 2</p>
<p>This version contains a fix for bug that cause some problem with MS Sql server execution plans (more details <a href="http://testdrivendevelopment.wordpress.com/2009/03/10/nhibernate-queries-sql-server-execution-plans/" target="_blank">here</a>). </p>
<p>Be carefull if you use an HQL query cause the actual parser is not still able to use the correct parameter type. I hope also this issue will be solved in the future versions but in the meantime you can use the solution I wrote in post linked above.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b158800d-7b24-4338-af8b-fdcf8ad3c92b" class="wlWriterEditableSmartContent">Technorati Tag: <a href="http://technorati.com/tags/NHibernate" rel="tag">NHibernate</a>,<a href="http://technorati.com/tags/NH2.1" rel="tag">NH2.1</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=85&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2009/06/21/nhibernate-2-1-0-beta-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ to NHibernate</title>
		<link>http://testdrivendevelopment.wordpress.com/2009/04/19/linq-to-nhibernate/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2009/04/19/linq-to-nhibernate/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 14:29:38 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[LinqToNHibernate]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2009/04/19/linq-to-nhibernate/</guid>
		<description><![CDATA[This is a very great news for NHibernate! Time for another update; it&#8217;s been a while since the last one. Good progress has been made on the new HQL AST Parser port from Hibernate, and it&#8217;s now in a state where it&#8217;s usable, passing the vast majority of the tests within the NHibernate test suite. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=84&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.imeta.co.uk/sstrong/archive/2009/04/16/680.aspx">This</a> is a very great news for NHibernate!</p>
<p><em>Time for another update; it&#8217;s been a while since the last one. Good progress has been made on the new HQL AST Parser port from Hibernate, and it&#8217;s now in a state where it&#8217;s usable, passing the vast majority of the tests within the NHibernate test suite. Of those that are failing (around 8 out of over 1600), we are currently discussing on the developers group whether we will live with these minor breaking changes, or do continued work on the parser to get everything passing.</em></p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:83e2cea7-c49d-41bf-904a-21b8b9bb696e" class="wlWriterEditableSmartContent">Technorati Tag: <a href="http://technorati.com/tags/LinqToNHibernate" rel="tag">LinqToNHibernate</a>,<a href="http://technorati.com/tags/Linq" rel="tag">Linq</a>,<a href="http://technorati.com/tags/NHibernate" rel="tag">NHibernate</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=84&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2009/04/19/linq-to-nhibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>
	</item>
		<item>
		<title>NHibernate queries &amp; sql server execution plans</title>
		<link>http://testdrivendevelopment.wordpress.com/2009/03/10/nhibernate-queries-sql-server-execution-plans/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2009/03/10/nhibernate-queries-sql-server-execution-plans/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 20:57:06 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Query execution plan]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2009/03/10/nhibernate-queries-sql-server-execution-plans/</guid>
		<description><![CDATA[In these days I’m working with Andrea on a web application using ASP.NET &#38; SQL Server . You should kwon that Andrea, is a SQL Server MVP, but fortunately is not a T-SQL taliban so he agree without hesitation when I proposed to use NHibernate to build our data access layer. When a tool can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=80&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In these days I’m working with <a href="http://community.ugiss.org/blogs/abenedetti">Andrea</a> on a web application using ASP.NET &amp; SQL Server . You should kwon that <a href="http://community.ugiss.org/blogs/abenedetti">Andrea</a>, is a SQL Server MVP, but fortunately is not a T-SQL taliban so he agree without hesitation when I proposed to use NHibernate to build our data access layer. When a tool can help us while building an application why not use it ?</p>
<p>As you can image a skilled DBA like <a href="http://community.ugiss.org/blogs/abenedetti">Andrea</a> can rapidly find a bottleneck in any query fired to a database. While writing a simple query using NHibernate API we noticed a strange behavior of NHibernate 2.0 with parameters. Here is the code we wrote:</p>
<pre style="width:697px;height:206px;"><span style="color:#0000ff;">using</span> (ISession session = factory.OpenSession())
{
	<span style="color:#008000;">//nvarchar(4)</span>
	session.CreateQuery(&quot;<span style="color:#8b0000;">from Region r where r.Description like :desc</span>&quot;)
		.SetString(&quot;<span style="color:#8b0000;">desc</span>&quot;, &quot;<span style="color:#8b0000;">zon%</span>&quot;)
		.List();

	<span style="color:#008000;">//nvarchar(5)</span>
	session.CreateQuery(&quot;<span style="color:#8b0000;">from Region r where r.Description like :desc</span>&quot;)
		.SetString(&quot;<span style="color:#8b0000;">desc</span>&quot;, &quot;<span style="color:#8b0000;">zone%</span>&quot;)
		.List();
}</pre>
<p>This code generates these two sql queries:</p>
<pre style="width:697px;height:167px;">

<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=exec&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">exec</a> <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=sp_executesql&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">sp_executesql</a> N'<span style="color:#8b0000;">select region0_.RegionId as RegionId0_, region0_.RegionDescription as RegionDe2_0_ </span><span style="color:#8b0000;">from Region region0_ where (region0_.RegionDescription like @p0 )</span>',N'<span style="color:#8b0000;">@p0 nvarchar(4)</span>',@p0=N'<span style="color:#8b0000;">zon%</span>'

<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=exec&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">exec</a> <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=sp_executesql&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">sp_executesql</a> N'<span style="color:#8b0000;">select region0_.RegionId as RegionId0_, region0_.RegionDescription as RegionDe2_0_ </span><span style="color:#8b0000;">from Region region0_ where (region0_.RegionDescription like @p0 )</span>',N'<span style="color:#8b0000;">@p0 nvarchar(5)</span>',@p0=N'<span style="color:#8b0000;">zone%</span>'
</pre>
<p>As you can see the parameter type is different in the two statements. This unfortunately cause SqlServer to generate two different exection plans. If you need the best performace you should avoid this behaviour. If you send to the database queries using the same parameter (type &amp; size) SqlServer use his internal cache. You have already pay for it so why not to use it ?</p>
<p>I had the pleasure to discuss with Fabio Maulo about this topic (you can read <a href="http://groups.google.it/group/nh-it/browse_thread/thread/2925264ff8aad4c2">here</a>. The conversation is in italian). At the end I found this solution:</p>
<p>I edited my hibernate.cfg.xml file adding this node to the xml</p>
<pre><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span>=<span style="color:#0000ff;">&quot;prepare_sql&quot;</span><span style="color:#0000ff;">&gt;</span>true<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">property</span><span style="color:#0000ff;">&gt;</span></pre>
<p>and then I wrote this code:</p>
<pre style="width:696px;height:223px;"><span style="color:#0000ff;">using</span> (ISession session = factory.OpenSession())
{

	<span style="color:#008000;">//nvarchar(10)</span>
	session.CreateQuery(&quot;<span style="color:#8b0000;">from Region r where r.Description like :desc</span>&quot;)
		.SetParameter(&quot;<span style="color:#8b0000;">desc</span>&quot;, &quot;<span style="color:#8b0000;">zoneh%</span>&quot;, TypeFactory.GetStringType(10))
		.List();

	<span style="color:#008000;">//nvarchar(10)</span>
	session.CreateQuery(&quot;<span style="color:#8b0000;">from Region r where r.Description like :desc</span>&quot;)
		.SetParameter(&quot;<span style="color:#8b0000;">desc</span>&quot;, &quot;<span style="color:#8b0000;">neh%</span>&quot;, TypeFactory.GetStringType(10))
		.List();
}</pre>
<p>Now with this code NHibernate generates these two sql queries:</p>
<pre style="width:697px;height:250px;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=declare&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">declare</a> @p1 <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=int&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">int</a>
<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=set&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">set</a> @p1=1
<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=exec&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">exec</a> <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=sp_prepexec&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">sp_prepexec</a> @p1 <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=output&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">output</a>,N'<span style="color:#8b0000;">@p0 nvarchar(10)</span>',N'<span style="color:#8b0000;">select region0_.RegionId as RegionId0_, region0_.RegionDescription as RegionDe2_0_ from Region region0_ where (region0_.RegionDescription like @p0 )</span>',@p0=N'<span style="color:#8b0000;">zoneh%</span>'
select @p1

<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=declare&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">declare</a> @p1 <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=int&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">int</a>
<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=set&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">set</a> @p1=2
<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=exec&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">exec</a> <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=sp_prepexec&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">sp_prepexec</a> @p1 <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=output&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">output</a>,N'<span style="color:#8b0000;">@p0 nvarchar(10)</span>',N'<span style="color:#8b0000;">select region0_.RegionId as RegionId0_, region0_.RegionDescription as RegionDe2_0_ from Region region0_ where (region0_.RegionDescription like @p0 )</span>',@p0=N'<span style="color:#8b0000;">neh%</span>'
select @p1</pre>
<p>This is better cause the parameters length is always the same. Now your database will thank you for this! But wait you can still do something better.<br />
  <br />If your database column type is a varchar and not nvarchar you can improve your code using a different SqlDbType. How ? Whit his code:</p>
<pre style="width:694px;height:179px;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=using&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">using</a> (ISession <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=session&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">session</a> = factory.OpenSession())
{
	<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=session&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">session</a>.CreateQuery(&quot;<span style="color:#8b0000;">from Region r where r.Description like :desc</span>&quot;)
		.SetParameter(&quot;<span style="color:#8b0000;">desc</span>&quot;, &quot;<span style="color:#8b0000;">z%</span>&quot;, TypeFactory.GetAnsiStringType(15))
		.List();

	<a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=session&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">session</a>.CreateQuery(&quot;<span style="color:#8b0000;">from Region r where r.Description like :desc</span>&quot;)
		.SetParameter(&quot;<span style="color:#8b0000;">desc</span>&quot;, &quot;<span style="color:#8b0000;">za%</span>&quot;, TypeFactory.GetAnsiStringType(15))
		.List();
}</pre>
<p>Now the parameter type is a varchar and the size is always 15. Whit this latest improvement you remove a CONVER_IMPLICIT operation from your query execution plan (futher details <a href="http://community.ugiss.org/blogs/abenedetti/archive/2009/03/03/ancora-su-query-e-sulla-definizione-dei-parametri-perfomance-e-piani-di-esecuzione.aspx">here</a> but in italian ). This cast operation cost something so if you don’t need it why to remove it ? </p>
<p>I hope this will help someone (dev &amp; dba) in the future!</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:955906c9-8de5-4d71-aba2-1031ea316d18" style="display:inline;float:none;margin:0;padding:0;">Technorati Tag: <a href="http://technorati.com/tags/NHibernate" rel="tag">NHibernate</a>,<a href="http://technorati.com/tags/SQLServer" rel="tag">SQLServer</a>,<a href="http://technorati.com/tags/Query+execution+plan" rel="tag">Query execution plan</a>,<a href="http://technorati.com/tags/ORM" rel="tag">ORM</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/testdrivendevelopment.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/testdrivendevelopment.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/testdrivendevelopment.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/testdrivendevelopment.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&amp;blog=2459763&amp;post=80&amp;subd=testdrivendevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2009/03/10/nhibernate-queries-sql-server-execution-plans/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>
	</item>
	</channel>
</rss>
