<?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>Software engineering and other considerations provided by</title>
	<atom:link href="https://benoit808.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://benoit808.wordpress.com</link>
	<description>Benoit Martin</description>
	<lastBuildDate>Tue, 23 Aug 2011 20:37:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<site xmlns="com-wordpress:feed-additions:1">4840422</site><cloud domain='benoit808.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://secure.gravatar.com/blavatar/289e8f1bc618f29f18bf56c7843e5003dc2827159c5f5bc64ccd4e4b469567c6?s=96&#038;d=https%3A%2F%2Fs0.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Software engineering and other considerations provided by</title>
		<link>https://benoit808.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://benoit808.wordpress.com/osd.xml" title="Software engineering and other considerations provided by" />
	<atom:link rel='hub' href='https://benoit808.wordpress.com/?pushpress=hub'/>
	<item>
		<title>Fixing the ClassNotFoundException when running cassandra-cli</title>
		<link>https://benoit808.wordpress.com/2011/08/23/fixing-the-classnotfoundexception-when-running-cassandra-cli/</link>
					<comments>https://benoit808.wordpress.com/2011/08/23/fixing-the-classnotfoundexception-when-running-cassandra-cli/#respond</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Tue, 23 Aug 2011 20:37:22 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[cassandra]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/?p=261</guid>

					<description><![CDATA[A problem I have seen frequently reported when trying to run cassandra-cli is the ClassNotFoundException. The most likely cause of this exception is a problem with the cassandra_home path. You have to make sure you have the correct path to the Cassandra root directory in your enviornment variables. &#8211; If it doesn&#8217;t already exist, add [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>A problem I have seen frequently reported when trying to run cassandra-cli is the ClassNotFoundException.<br />
The most likely cause of this exception is a problem with the cassandra_home path.</p>
<p>You have to make sure you have the correct path to the Cassandra root directory in your enviornment variables.<br />
&#8211; If it doesn&#8217;t already exist, add a user/system variable called CASSANDRA_HOME.<br />
&#8211; Set it to <code>/<em>your_path_to_cassandra</em>/apache-casssandra-0.8.4</code> or <code>c:\<em>your_path_to_cassandra</em>\apache-casssandra-0.8.4</code> depending on your system.</p>
<p>This should solve the problem</p>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2011/08/23/fixing-the-classnotfoundexception-when-running-cassandra-cli/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">261</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>Finding out public IP from console on Linux</title>
		<link>https://benoit808.wordpress.com/2010/10/26/finding-out-public-ip-from-console-on-linux/</link>
					<comments>https://benoit808.wordpress.com/2010/10/26/finding-out-public-ip-from-console-on-linux/#respond</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Tue, 26 Oct 2010 18:56:01 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/?p=254</guid>

					<description><![CDATA[My site of choice to lookup my public IP is http://www.whatismyip.com. This is very easy to use from a browser but not as straight forward if you only have access to the console. The trick is to use wget and a regular expression to extrac the IP address. The script below is taken from wolfvorkian1 at http://ubuntuforums.org/archive/index.php/t-228660.html [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>My site of choice to lookup my public IP is <a href="http://www.whatismyip.com" rel="nofollow">http://www.whatismyip.com</a>. This is very easy to use from a browser but not as straight forward if you only have access to the console. The trick is to use wget and a regular expression to extrac the IP address.</p>
<p>The script below is taken from <em>wolfvorkian1 </em>at <a href="http://ubuntuforums.org/archive/index.php/t-228660.html">http://ubuntuforums.org/archive/index.php/t-228660.html</a></p>
<pre>wget -qO - www.whatismyip.com/automation/n09230945.asp | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
</pre>
<p>This will just display your external public IP</p>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/10/26/finding-out-public-ip-from-console-on-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">254</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>Deleting all folders and sub-folders with a given name with Windows Shell</title>
		<link>https://benoit808.wordpress.com/2010/10/14/deleting-all-folders-and-sub-folders-with-a-given-name-with-windows-shell/</link>
					<comments>https://benoit808.wordpress.com/2010/10/14/deleting-all-folders-and-sub-folders-with-a-given-name-with-windows-shell/#comments</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Thu, 14 Oct 2010 18:41:59 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[windows]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/?p=251</guid>

					<description><![CDATA[This particular script came in handy when I copied a project that was under source control with SVN and wanted to &#8220;unbind&#8221; it. The easiest way to do that is to delete all the .svn folders and sub-folders inside the project&#8217;s directory. This could be achieved by doing a search in Windows for &#8220;.svn&#8221;, selecting all the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>This particular script came in handy when I copied a project that was under source control with SVN and wanted to &#8220;unbind&#8221; it. The easiest way to do that is to delete all the .svn folders and sub-folders inside the project&#8217;s directory.</p>
<p>This could be achieved by doing a search in Windows for &#8220;.svn&#8221;, selecting all the returned directories and deleting them. But if this way is not an option, here is a scrip that will do the trick:</p>
<pre>for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (  rd /s /q "%%i")
</pre>
<ol>
<li>create a file with any text editor</li>
<li>paste this script in</li>
<li>save it with a .cmd extension (e.g. delete_svn.cmd)</li>
<li>there are 2 ways to run the script:
<ul>
<li>from the Command Prompt
<ul>
<li> go to the top directory where you want to do the deletion (let&#8217;s call it working directory)</li>
<li>type [path_to_cmd_file]\delete_svn.cmd and then Enter</li>
</ul>
</li>
</ul>
<ul>
<li>from the Windows Explorer
<ul>
<li>copy the .cmd file to the working directory</li>
<li>double-click on it</li>
</ul>
</li>
</ul>
</li>
</ol>
<p>This should take care of recursively deleting all the directories called .svn</p>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/10/14/deleting-all-folders-and-sub-folders-with-a-given-name-with-windows-shell/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">251</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting color from resource on Android</title>
		<link>https://benoit808.wordpress.com/2010/09/09/setting-color-from-resource-on-android/</link>
					<comments>https://benoit808.wordpress.com/2010/09/09/setting-color-from-resource-on-android/#comments</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 07:03:37 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[sdk]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/?p=241</guid>

					<description><![CDATA[It is straight forward to set a color for text or background for example with the Android SDK but there is a mistake I made several times when getting started and this is what I want to cover in this short post. Let&#8217;s take the example of setting the background color of a View and [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>It is straight forward to set a color for text or background for example with the Android SDK but there is a mistake I made several times when getting started and this is what I want to cover in this short post.</p>
<p>Let&#8217;s take the example of setting the background color of a View and following the best practices, we want to use a color defined in <code>colors.xml</code> in the <code>values</code> directory of <code>res</code>.</p>
<p>The signature for the method used is <code><span style="color:#0000ff;">setBackgroundColor(int color)</span></code></p>
<p>The mistake I made was to call it as <code><span style="color:#0000ff;">myView.setBackgroundColor(R.colors.my_color)</span></code> which does not trigger any warnings or errors at compile time nor at runtime but will give you grey no matter what color code you defined.</p>
<p>When thinking about it, it makes sense because <code><span style="color:#0000ff;">R.colors.my_color</span></code> returns the id value of the resource and not the actual color defined by the resource. So what we need to write instead is:<br />
<code><span style="color:#0000ff;">myView.setBackgroundColor(getResources().getColor(R.colors.my_color))</span></code></p>
<p><strong>Note:</strong> if you are calling this outside of an Activity class or a class extending Activity, you need to specify the context for getResources so you may end-up with something like this:<br />
<code><span style="color:#0000ff;">myView.setBackgroundColor(context.getResources().getColor(R.colors.my_color))</span></code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/09/09/setting-color-from-resource-on-android/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">241</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting &#8220;The process cannot access the file because it is being used by another process&#8221; when trying to start a website</title>
		<link>https://benoit808.wordpress.com/2010/09/07/getting-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process-when-trying-to-start-a-website/</link>
					<comments>https://benoit808.wordpress.com/2010/09/07/getting-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process-when-trying-to-start-a-website/#respond</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Tue, 07 Sep 2010 18:41:14 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[iis]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/?p=234</guid>

					<description><![CDATA[Today when trying to start a website that was mysteriously stopped on my development machine, I got the following error message: The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020) This is a very misleading error message and I spent some time looking at my running [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Today when trying to start a website that was mysteriously stopped on my development machine, I got the following error message:<br />
<code>The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)</code></p>
<p>This is a very misleading error message and I spent some time looking at my running processes and checking with EMCO&#8217;s UnlockIT to try figuring out what was locking my files. Looking at the Events log gives a little more accurate error that looks like this:</p>
<p><code>Source: HttpEvent<br />
Msg: Unable to bind to the underlying transport for [::]:80. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine. The data field contains the error number.<br />
--------------------------------------------------------------<br />
 Source: IIS-W3SVC<br />
Msg: The World Wide Web Publishing Service (WWW Service) did not register the URL prefix http://*:80/ for site 1. The site has been disabled. The data field contains the error number.</code></p>
<p>The actual issue is actually about the binding of the site. It you have any other process using port 80 (or whatever port you assigned to this site), you will get that error message when trying to start it.</p>
<p>To solve this problem, you have 2 options:<br />
1. Change the port number for the problematic site&#8217;s binding to any available port<br />
2. Turn off the service using the conflicting port (you can also assign a different port to that service)</p>
<p>All-in-all, this is a very minor problem that can be very easily resolved but the initial error message is leading us down the wrong path.</p>
<p>Hope this will help someone with the same issue</p>
<p>Note: my environment is Windows 7 x86 and running IIS 7.5</p>
<p><strong>Update</strong>: Just finally found out that what took over my port 80 was Skype. No idea why and I have no intention on finding out so from now on, Skype is off.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/09/07/getting-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process-when-trying-to-start-a-website/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">234</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>Disabling relay for localhost SMTP server (Sendmail) on Linux</title>
		<link>https://benoit808.wordpress.com/2010/06/11/disabling-relay-for-localhost-smtp-server-sendmail-on-linux/</link>
					<comments>https://benoit808.wordpress.com/2010/06/11/disabling-relay-for-localhost-smtp-server-sendmail-on-linux/#comments</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Fri, 11 Jun 2010 16:13:03 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[localhost]]></category>
		<category><![CDATA[relay]]></category>
		<category><![CDATA[smtp]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/2010/06/11/disabling-relay-for-localhost-smtp-server-sendmail-on-linux/</guid>

					<description><![CDATA[Why would one want to do that? Well, I am in a situation where I need to load test a server and one of the tasks accomplished by that server is to send out emails. I want the test to be as close to a production scenario without actually sending out the emails. Many options [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Why would one want to do that?</p>
<p>Well, I am in a situation where I need to load test a server and one of the tasks accomplished by that server is to send out emails. I want the test to be as close to a production scenario without actually sending out the emails. Many options came to my mind but none of them would have provided what I was looking for:   <br />&#8211; turning off the SMTP server: the application would have to wait for the connection to timeout which skews our tests    <br />&#8211; using random invalid email addresses as destination: that would result in a bunch of bounce backs which is not, again, what is happening in production    <br />etc…</p>
<p>The best way was to have my application point at the localhost SMTP server (Sendmail) and disable relaying to the emails never actually get sent to their destination. The description below assumes that you are using the default configuration of <strong>Sendmail</strong> which manages relaying permissions using the access file. </p>
<p>To accomplish what I wanted, all I had to do was edit the <strong>access</strong> file located in<strong> /etc/mail/     <br /></strong>In that file, for each source, there are 4 possible values: <strong>OK</strong>, <strong>RELAY</strong>, <strong>REJECT</strong> and <strong>DISCARD</strong>. OK relays even if other rules are not satisfied, RELAY enables relaying for this source and REJECT rejects the emails and sends a message back. The one we are interested in is DISCARD which just silently discards the message without generating an error message. It almost turns out SMTP server into a mock server.</p>
<p>So, the 3 lines we had to modify were:   <br />Connect:localhost&#160;&#160;&#160;&#160;&#160;&#160;&#160; DISCARD    <br />Connect:127&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DISCARD    <br />Connect:[IPv6:::1]&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DISCARD</p>
<p>This will cover all local requests using IPv4 and IPv6. </p>
<p>Final step is to restart sendmail for those changes to take effect: <strong>sudo /etc/init.d/sendmail restart</strong></p>
<p>Note: you will need sudo to edit the access file.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/06/11/disabling-relay-for-localhost-smtp-server-sendmail-on-linux/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">228</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>Animation speeds in SQL Server Management Studio</title>
		<link>https://benoit808.wordpress.com/2010/02/11/animation-speeds-in-sql-server-management-studio/</link>
					<comments>https://benoit808.wordpress.com/2010/02/11/animation-speeds-in-sql-server-management-studio/#respond</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Thu, 11 Feb 2010 18:54:27 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[ssms]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/?p=212</guid>

					<description><![CDATA[Wow, I can&#8217;t believe this is not available in the options and that we have to resort to edit config files. Anyway, big thanks to Euan for this tip : Close SQL Server Management Studio. Open this file in a text editor Win XP: C:\Documents and Settings\&#60;username&#62;\My Documents\SQL Server Management Studio\Settings\CurrentSettings\&#60;yyyy-mm-dd&#62;.vssettings Win Vista/7: C:\Users\&#60;username&#62;\Documents\SQL Server [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Wow, I can&#8217;t believe this is not available in the options and that we have to resort to edit config files.</p>
<p>Anyway, big thanks to <a href="//blogs.msdn.com/euanga/archive/2007/10/01/ssms-window-animation-speed.aspx" target="_blank">Euan </a>for this tip :</p>
<blockquote>
<ol>
<li><span style="font-size:x-small;">Close </span><span style="font-size:x-small;">SQL Server Management  Studio.</span></li>
<li><span style="font-size:x-small;">Open this file in a text editor </span><span style="font-size:x-small;"><br />
Win XP: C:\Documents and  Settings\&lt;username&gt;\My Documents\SQL Server Management  Studio\Settings\CurrentSettings\&lt;yyyy-mm-dd&gt;.vssettings<br />
Win Vista/7: </span>C:\Users\&lt;username&gt;\Documents\SQL Server Management Studio\Settings<span style="font-size:x-small;">\CurrentSettings</span><span style="font-size:x-small;">\&lt;yyyy-mm-dd&gt;.vssettings</span></li>
<li><span style="font-size:x-small;">Search for &#8220;AnimationSpeed&#8221; and replace the existing value (5) with your  desired speed; 10 being the fastest choice, I do not know what is the  lowest (1?). Save.</span></li>
<li><span style="font-size:x-small;">Open SQL Server Management Studio and it should now animate at your  desired speed.</span></li>
</ol>
</blockquote>
<p>A couple of notes:</p>
<ul>
<li>&lt;yyyy-mm-dd&gt; is a time stamp because several versions of the config file are saved with different names. Obviously, you will want to edit the one with the most recent date</li>
<li>In addition to setting the animation speed, there is also a setting called Animation that can be set to false and will eliminate the animations altogether.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/02/11/animation-speeds-in-sql-server-management-studio/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">212</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>Calling a Stored Procedure as part of a NHibernate transaction</title>
		<link>https://benoit808.wordpress.com/2010/02/10/calling-a-stored-procedure-as-part-of-a-nhibernate-transaction/</link>
					<comments>https://benoit808.wordpress.com/2010/02/10/calling-a-stored-procedure-as-part-of-a-nhibernate-transaction/#respond</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Wed, 10 Feb 2010 22:44:33 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[sql]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/2010/02/10/calling-a-stored-procedure-as-part-of-a-nhibernate-transaction/</guid>

					<description><![CDATA[The scenario Today I had the need to call a stored procedure after some domain objects got updated. Those domain objects are persisted via NHibernate. The question here is not whether it’s good or not to have calls to sprocs mixed with NHibernate persistence because this can be argued but sometimes you have no choice [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>The scenario</strong></p>
<p>Today I had the need to call a stored procedure after some domain objects got updated. Those domain objects are persisted via NHibernate. The question here is not whether it’s good or not to have calls to sprocs mixed with NHibernate persistence because this can be argued but sometimes you have no choice when dealing with legacy code.</p>
<p>This is all in the context of an asp.net application with a SQL Server database.</p>
<p><strong>The problem</strong></p>
<p>The root of the problem I faced was that we are using a DAO pattern where a NHibernate session is started at the beginning of a request and closed at the end of the request.</p>
<p>My first approach was to do my objects updates and then call a method in my data access layer executing the stored procedure through ADO.NET. The problem with this was that the changes done to the objects are not persisted into the database until the session closed and the transaction committed. As a result, the stored procedure was run immediately and my update statements issued afterward.</p>
<p>I then thought that all I had to do was flush my NHibernate session before I exec the sproc to commit my changes to the database. However, for some reason that created some lock or pending session somewhere so my ado.net connection attempt timed out.</p>
<p><strong>The solution</strong></p>
<p>The idea of flushing the session and then executing the sproc was close but the last missing piece was to call the sproc via NHibernate using the same session as opposed to ADO.NET. My code ended up looking like this:</p>
<p><code><br />
// flush the NHibernate session to commit changes<br />
Session.Flush();</code></p>
<p><code>// execute the stored procedure<br />
IQuery query = Session.CreateSQLQuery("exec MySprocName @param=:param1");<br />
query.SetString("param1", data);<br />
query.ExecuteUpdate();</code></p>
<p>Hope this helps</p>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/02/10/calling-a-stored-procedure-as-part-of-a-nhibernate-transaction/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">208</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>Mozilla Weave Sync, FAIL!</title>
		<link>https://benoit808.wordpress.com/2010/02/08/mozilla-weave-sync-fail/</link>
					<comments>https://benoit808.wordpress.com/2010/02/08/mozilla-weave-sync-fail/#respond</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Tue, 09 Feb 2010 01:31:23 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/2010/02/08/mozilla-weave-sync-fail/</guid>

					<description><![CDATA[I decided to install Mozilla weave when they released version 1.0 after being bin beta for years. I assumed they had enough time to work out the kinks and that the 1.0 tag meant it was going to be stable. But no, my bookmarks got moved around, taken out of folders, duplicated&#8230; very disappointing!]]></description>
										<content:encoded><![CDATA[<p>I decided to install Mozilla weave when they released version 1.0 after being bin beta for years. I assumed they had enough time to work out the kinks and that the 1.0 tag meant it was going to be stable.<br />
But no, my bookmarks got moved around, taken out of folders, duplicated&#8230; very disappointing!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/02/08/mozilla-weave-sync-fail/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">207</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
		<item>
		<title>WILT: Query by Criteria with clause on component property with NHibernate</title>
		<link>https://benoit808.wordpress.com/2010/02/08/wilt-query-by-criteria-with-clause-on-component-property-with-nhibernate/</link>
					<comments>https://benoit808.wordpress.com/2010/02/08/wilt-query-by-criteria-with-clause-on-component-property-with-nhibernate/#respond</comments>
		
		<dc:creator><![CDATA[benoit808]]></dc:creator>
		<pubDate>Mon, 08 Feb 2010 10:14:00 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[What I Learned Today]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[NHibernate]]></category>
		<guid isPermaLink="false">http://benoit808.wordpress.com/?p=202</guid>

					<description><![CDATA[It took me a little bit to figure this one out but it makes sense and it’s pretty simple once we know: Let’s say I have a class MyFirstClass with a component of type MySecondClass and I want to write a query to retrieve all MyFirstClass objects where the ID of MySecondClass is 1. My [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>It took me a little bit to figure this one out but it makes sense and it’s pretty simple once we know:</p>
<p>Let’s say I have a class MyFirstClass with a component of type MySecondClass and I want to write a query to retrieve all MyFirstClass objects where the ID of MySecondClass is 1.<br />
My first attempt went like this:</p>
<div>
<pre class="csharpcode">Session.CreateCriteria(<span class="kwrd">typeof</span>(MyFirstClass)
   .Add(NHibernate.Criterion.Expression
     .Eq(<span class="str">"MySecondClass.ID"</span>, <span class="str">"1"</span>));</pre>
</div>
<div>That didn’t work because NHibernate doesn’t understand what I meant with MySecondClass.ID.</div>
<div></div>
<div>The solution is simply to use a sub criteria like so:</div>
<div id="codeSnippetWrapper">
<pre class="csharpcode">Session.CreateCriteria(<span class="kwrd">typeof</span>(MyFirstClass)
  .CreateCriteria(<span class="str">"MySecondClass"</span>)
    .Add(NHibernate.Criterion.Expression
      .Eq(<span class="str">"ID"</span>, <span class="str">"1"</span>));</pre>
<p>It is important to notice that the sub criteria is created using the Property name</p>
</div>
<div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://benoit808.wordpress.com/2010/02/08/wilt-query-by-criteria-with-clause-on-component-property-with-nhibernate/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">202</post-id>
		<media:content url="https://0.gravatar.com/avatar/604da268593354c5c5b1a3f6b04294111563430894de7c8fefaa41ea68c1bb01?s=96&#38;d=https%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">benoit808</media:title>
		</media:content>
	</item>
	</channel>
</rss>
