<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for Nelson Montalvo&#039;s Blog</title>
	<atom:link href="http://lostechies.com/nelsonmontalvo/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/nelsonmontalvo</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Thu, 24 Mar 2011 19:28:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>Comment on NHibernate Query Example using CreateCriteria by Brandy Swift</title>
		<link>http://lostechies.com/nelsonmontalvo/2008/04/13/nhibernate-query-example-using-createcriteria/#comment-31</link>
		<dc:creator>Brandy Swift</dc:creator>
		<pubDate>Thu, 24 Mar 2011 19:28:33 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2008/04/13/nhibernate-query-example-using-createcriteria.aspx#comment-31</guid>
		<description>It is extremely interesting for me to read the article. Thanx for it. I like such topics and anything that is connected to them. I would like to read more on that site soon.         
        
Brandy  Swift        
&lt;a href=&quot;http://www.phone-blocker.com/&quot; rel=&quot;nofollow&quot;&gt;mobile jammer&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>It is extremely interesting for me to read the article. Thanx for it. I like such topics and anything that is connected to them. I would like to read more on that site soon.         </p>
<p>Brandy  Swift<br />
<a href="http://www.phone-blocker.com/" rel="nofollow">mobile jammer</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simple NHibernate Example, Part 4 : Session Management by Donna</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/03/30/simple-nhibernate-example-part-4-session-management/#comment-8</link>
		<dc:creator>Donna</dc:creator>
		<pubDate>Sat, 22 Nov 2008 00:55:15 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/03/30/simple-nhibernate-example-part-4-session-management.aspx#comment-8</guid>
		<description>It&#039;s been 1.5 years... upcoming post still up &amp; coming?</description>
		<content:encoded><![CDATA[<p>It&#8217;s been 1.5 years&#8230; upcoming post still up &#038; coming?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simple NHibernate Example, Part 5: Repository Testing by Nelson Montalvo</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/04/04/simple-nhibernate-example-part-5-repository-testing/#comment-15</link>
		<dc:creator>Nelson Montalvo</dc:creator>
		<pubDate>Sun, 13 Apr 2008 07:33:39 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/04/03/simple-nhibernate-example-part-5-repository-testing.aspx#comment-15</guid>
		<description>@jack

Sorry, haven&#039;t had much time and still don&#039;t, so here goes:

1. I believe that a) it&#039;s more appropriate to use it when your unit of work is, for example, at the request level in a web application. I think this is referred to as the session per request. When a request comes in to an asp.net application, it normally last only a few seconds, so opening a session at the beginning of the request is ok. Honestly, I haven&#039;t thought through a lot of scenarios like this so, but for both a) and b) I would say that you are putting the session into context and just reaching into context whenever you need session. The difference is whether you are reaching into httpcontext on a web application or call context for pretty much all other types of apps. Please search for the difference between the two, it&#039;s important. Also, NHibernate 2.0 nicely handles the difference between the two with a session context manager (I&#039;m not sure if it was available in earlier versions).

Finally, note that you can have more than one session open per context. the other sessions might point to other databases, for example. Your repository would have to konw how to ask for the correct one. Perhaps injecting the repository with some way to do that would facilitate this.

2a) I fully agree. Transaction management doesn&#039;t necessarily have to be explicit at the app/domain level. It can be hidden through a facade: (UnitOfWork.InitWork) opens a new transaction under the covers, for example. For the most part, allow the transaction management to occur outside the repositories.

2b) I like the analogy.However, I don&#039;t know if the repositories should be handling session/trnsaction issues. I suppose there are cases where you might want to. I keep that at the app level. So I suppose some of your internals can be exposed at the app level (via exceptions), but this is usually not a big deal if you allow your facade to handle the issues by delegating (UnitOfWork.RecoveFrom(blah) or whatever). </description>
		<content:encoded><![CDATA[<p>@jack</p>
<p>Sorry, haven&#8217;t had much time and still don&#8217;t, so here goes:</p>
<p>1. I believe that a) it&#8217;s more appropriate to use it when your unit of work is, for example, at the request level in a web application. I think this is referred to as the session per request. When a request comes in to an asp.net application, it normally last only a few seconds, so opening a session at the beginning of the request is ok. Honestly, I haven&#8217;t thought through a lot of scenarios like this so, but for both a) and b) I would say that you are putting the session into context and just reaching into context whenever you need session. The difference is whether you are reaching into httpcontext on a web application or call context for pretty much all other types of apps. Please search for the difference between the two, it&#8217;s important. Also, NHibernate 2.0 nicely handles the difference between the two with a session context manager (I&#8217;m not sure if it was available in earlier versions).</p>
<p>Finally, note that you can have more than one session open per context. the other sessions might point to other databases, for example. Your repository would have to konw how to ask for the correct one. Perhaps injecting the repository with some way to do that would facilitate this.</p>
<p>2a) I fully agree. Transaction management doesn&#8217;t necessarily have to be explicit at the app/domain level. It can be hidden through a facade: (UnitOfWork.InitWork) opens a new transaction under the covers, for example. For the most part, allow the transaction management to occur outside the repositories.</p>
<p>2b) I like the analogy.However, I don&#8217;t know if the repositories should be handling session/trnsaction issues. I suppose there are cases where you might want to. I keep that at the app level. So I suppose some of your internals can be exposed at the app level (via exceptions), but this is usually not a big deal if you allow your facade to handle the issues by delegating (UnitOfWork.RecoveFrom(blah) or whatever). </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simple NHibernate Example, Part 5: Repository Testing by Josh Schwartzberg</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/04/04/simple-nhibernate-example-part-5-repository-testing/#comment-14</link>
		<dc:creator>Josh Schwartzberg</dc:creator>
		<pubDate>Wed, 09 Apr 2008 00:48:35 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/04/03/simple-nhibernate-example-part-5-repository-testing.aspx#comment-14</guid>
		<description>Hmm, the download link for this article doesn&#039;t work anymore.  Any chance you could fix that?</description>
		<content:encoded><![CDATA[<p>Hmm, the download link for this article doesn&#8217;t work anymore.  Any chance you could fix that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simple NHibernate Example, Part 5: Repository Testing by jack</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/04/04/simple-nhibernate-example-part-5-repository-testing/#comment-13</link>
		<dc:creator>jack</dc:creator>
		<pubDate>Tue, 08 Apr 2008 07:13:46 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/04/03/simple-nhibernate-example-part-5-repository-testing.aspx#comment-13</guid>
		<description>Hi, thanks for you quick reply. 
You have put more light on the issue. Good work!!
I am eagerly waiting for your NHibernateRepository example with lazy root traversal. A simple example, just illustrating the methodology will be ok. You did not need to provide full working codes.

The first link you provided me did not work. But I successfully make a trip to Fowlers website to see his own version of a repository. 

Here are some few more questions 
&quot;The key elements to me, with the implementation of a repository, tend to be session/transaction management and &quot;lazy&quot; traversals.&quot;
1)It is logical true that the first time setup of the session is expensive. some people have suggest to store it in the httpcontext variable. Which means use one session per context. (a) When is it right to use one session per context ? and (b) when it is right to use one session per &quot;unit of work&quot; ?
2) Evans of DDD, suggest that transaction management should be kept out of the repository and managed by the consumer of the repository since the consumer of the repository has a better knowledge of its &quot;unit of work &quot; boundaries. (a) what is your suggestion on this point? 
(b) let assume that our repository is a public tap  in a restaurant ( it provide us with water on demand). In the past when you want to wash you hands, you will move to the tap (new datacontext), open the tap (begintransaction), water flows out, you wash you hands, you close the tap (endtransaction) , and move away (dispose datacontext).  
Experience shows that obviously the user don&#039;t care about the opening and closing of the tap. all the user wants  is water to wash their hands. Today there are some intelligent taps with infra ray that will automatically open when you move infront of them and automatically close when you move away.  So how can we implement an intelligent repository that will internally handle sessions and transactions issuis which are obvious not the job of our business domain but that of the Data Access Layer.? 

Thanks for your work so far. 
</description>
		<content:encoded><![CDATA[<p>Hi, thanks for you quick reply.<br />
You have put more light on the issue. Good work!!<br />
I am eagerly waiting for your NHibernateRepository example with lazy root traversal. A simple example, just illustrating the methodology will be ok. You did not need to provide full working codes.</p>
<p>The first link you provided me did not work. But I successfully make a trip to Fowlers website to see his own version of a repository. </p>
<p>Here are some few more questions<br />
&#8220;The key elements to me, with the implementation of a repository, tend to be session/transaction management and &#8220;lazy&#8221; traversals.&#8221;<br />
1)It is logical true that the first time setup of the session is expensive. some people have suggest to store it in the httpcontext variable. Which means use one session per context. (a) When is it right to use one session per context ? and (b) when it is right to use one session per &#8220;unit of work&#8221; ?<br />
2) Evans of DDD, suggest that transaction management should be kept out of the repository and managed by the consumer of the repository since the consumer of the repository has a better knowledge of its &#8220;unit of work &#8221; boundaries. (a) what is your suggestion on this point?<br />
(b) let assume that our repository is a public tap  in a restaurant ( it provide us with water on demand). In the past when you want to wash you hands, you will move to the tap (new datacontext), open the tap (begintransaction), water flows out, you wash you hands, you close the tap (endtransaction) , and move away (dispose datacontext).<br />
Experience shows that obviously the user don&#8217;t care about the opening and closing of the tap. all the user wants  is water to wash their hands. Today there are some intelligent taps with infra ray that will automatically open when you move infront of them and automatically close when you move away.  So how can we implement an intelligent repository that will internally handle sessions and transactions issuis which are obvious not the job of our business domain but that of the Data Access Layer.? </p>
<p>Thanks for your work so far. </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simple NHibernate Example, Part 5: Repository Testing by Nelson Montalvo</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/04/04/simple-nhibernate-example-part-5-repository-testing/#comment-12</link>
		<dc:creator>Nelson Montalvo</dc:creator>
		<pubDate>Mon, 07 Apr 2008 22:33:09 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/04/03/simple-nhibernate-example-part-5-repository-testing.aspx#comment-12</guid>
		<description>I suppose that this one&#039;s up in the air in terms of differing opinions, so I&#039;ll caveat with IMO... lol.

Pretty much, a Repository (per Evan&#039;s DDD book) acts as the &quot;starting point for the traversal to an ENTITY or VALUE in the middle of its life cycle.&quot; Strictly speaking, it&#039;s a DOMAIN level concept abstracting out the work needed to acquire that aggregate root. Note that I have not talked anything about databases, DAOs, and whatnot. I think that it&#039;s easy to go to that level, but remember that the repository could be talking to an in-memory DB, a web service, and whatever else. The key elements to me, with the implementation of a repository, tend to be session/transaction management and &quot;lazy&quot; traversals.

All that being said, I mostly make interfaces out of the repositories in my domain. From here, I can implement the repository however I want, injecting the implementation as needed. A simple example utilizing NHibernate is here: http://codemonkey.nmonta.com/2008/04/02/simple-nhibernate-query-using-createcriteria/ and more information on implementing repositories are here: http://martinfowler.com/eaaCatalog/repository.html.

But getting back to your original points:

- I do not believe a repository HAS TO BE a wrapper or generic crud operator around &quot;all DAOs.&quot; If the point of the repository is to provide the domain with some sense of how to get the aggregate root, why can&#039;t the methods be business specific as opposed to generic? GetMyBadAssVehicle(string nameOfDriver) vs GetItem&lt;Vehicle&gt;(CriteriaObj criteria) where criteria might contain BadAss = true and the name of the driver. As your domain requirements change, so might your repository requirements, to the point where it makes more sense to have a generic repository.

- You do not ALWAYS have to traverse an aggregate root to reah another object. There are of course different ways to implement this, but based on your example, does the item have enough significance to be its own aggregate? If so, then it might be easier to build a repository querying that. If not, would you inject your repository/DAO implementation into the aggregate itself, so that lazy loading can occur? Or better yet, why not use NHibernate or other ORM and just save yourself all that trouble? :)

I&#039;ll see if I can put together a quick NHibernate example of lazy root traversals, so you can see it in all its glory. :)</description>
		<content:encoded><![CDATA[<p>I suppose that this one&#8217;s up in the air in terms of differing opinions, so I&#8217;ll caveat with IMO&#8230; lol.</p>
<p>Pretty much, a Repository (per Evan&#8217;s DDD book) acts as the &#8220;starting point for the traversal to an ENTITY or VALUE in the middle of its life cycle.&#8221; Strictly speaking, it&#8217;s a DOMAIN level concept abstracting out the work needed to acquire that aggregate root. Note that I have not talked anything about databases, DAOs, and whatnot. I think that it&#8217;s easy to go to that level, but remember that the repository could be talking to an in-memory DB, a web service, and whatever else. The key elements to me, with the implementation of a repository, tend to be session/transaction management and &#8220;lazy&#8221; traversals.</p>
<p>All that being said, I mostly make interfaces out of the repositories in my domain. From here, I can implement the repository however I want, injecting the implementation as needed. A simple example utilizing NHibernate is here: <a href="http://codemonkey.nmonta.com/2008/04/02/simple-nhibernate-query-using-createcriteria/" rel="nofollow">http://codemonkey.nmonta.com/2008/04/02/simple-nhibernate-query-using-createcriteria/</a> and more information on implementing repositories are here: <a href="http://martinfowler.com/eaaCatalog/repository.html" rel="nofollow">http://martinfowler.com/eaaCatalog/repository.html</a>.</p>
<p>But getting back to your original points:</p>
<p>- I do not believe a repository HAS TO BE a wrapper or generic crud operator around &#8220;all DAOs.&#8221; If the point of the repository is to provide the domain with some sense of how to get the aggregate root, why can&#8217;t the methods be business specific as opposed to generic? GetMyBadAssVehicle(string nameOfDriver) vs GetItem<vehicle>(CriteriaObj criteria) where criteria might contain BadAss = true and the name of the driver. As your domain requirements change, so might your repository requirements, to the point where it makes more sense to have a generic repository.</p>
<p>- You do not ALWAYS have to traverse an aggregate root to reah another object. There are of course different ways to implement this, but based on your example, does the item have enough significance to be its own aggregate? If so, then it might be easier to build a repository querying that. If not, would you inject your repository/DAO implementation into the aggregate itself, so that lazy loading can occur? Or better yet, why not use NHibernate or other ORM and just save yourself all that trouble? <img src='http://lostechies.com/nelsonmontalvo/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;ll see if I can put together a quick NHibernate example of lazy root traversals, so you can see it in all its glory. <img src='http://lostechies.com/nelsonmontalvo/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </vehicle></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simple NHibernate Example, Part 5: Repository Testing by jack</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/04/04/simple-nhibernate-example-part-5-repository-testing/#comment-11</link>
		<dc:creator>jack</dc:creator>
		<pubDate>Mon, 07 Apr 2008 18:15:39 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/04/03/simple-nhibernate-example-part-5-repository-testing.aspx#comment-11</guid>
		<description>&lt;p&gt;HI Nelson,&lt;/p&gt;
&lt;p&gt;I have been scrawling the web looking for information to help me implement a repository pattern for my custome layered architecture . &lt;/p&gt;
&lt;p&gt;i have read the repository pattern section of DDD, but what I have been seen arround on the web as implementation is no big difference from a wrapper of all DAOs into one class which is called &quot;repository&quot;. &#160;&lt;/p&gt;
&lt;p&gt;So what are the key differences between your Repository pattern implementation and simple DAO pattern implementation. &lt;/p&gt;
&lt;p&gt;I gues repository and DAO have two different strategy for getting objects out of the database. &#160;&lt;/p&gt;
&lt;p&gt;With the repository pattern, the root object ( aggregate root) is obtained first, and other associated object are loaded lazily as required by navigation down the association.&lt;/p&gt;
&lt;p&gt;For example to abtain a lineItem belonging to an order we do order.items.getItemByID(paramID);&lt;/p&gt;
&lt;p&gt;where order is a root aggregate.&lt;/p&gt;
&lt;p&gt;However, using DAO &#160;we simple do itemDAO.getItemsByID(paramID); where itemDAO may come from a factory.&lt;/p&gt;
&lt;p&gt;I do not see code or tutorials showing how to navigate down the root aggregate associations. Any suggestions ?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>HI Nelson,</p>
<p>I have been scrawling the web looking for information to help me implement a repository pattern for my custome layered architecture . </p>
<p>i have read the repository pattern section of DDD, but what I have been seen arround on the web as implementation is no big difference from a wrapper of all DAOs into one class which is called &#8220;repository&#8221;. &nbsp;</p>
<p>So what are the key differences between your Repository pattern implementation and simple DAO pattern implementation. </p>
<p>I gues repository and DAO have two different strategy for getting objects out of the database. &nbsp;</p>
<p>With the repository pattern, the root object ( aggregate root) is obtained first, and other associated object are loaded lazily as required by navigation down the association.</p>
<p>For example to abtain a lineItem belonging to an order we do order.items.getItemByID(paramID);</p>
<p>where order is a root aggregate.</p>
<p>However, using DAO &nbsp;we simple do itemDAO.getItemsByID(paramID); where itemDAO may come from a factory.</p>
<p>I do not see code or tutorials showing how to navigate down the root aggregate associations. Any suggestions ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on ReSharper Keymappings by Joe Ocampo</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/10/28/resharper-keymappings/#comment-30</link>
		<dc:creator>Joe Ocampo</dc:creator>
		<pubDate>Sun, 28 Oct 2007 18:35:41 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/10/28/resharper-keymappings.aspx#comment-30</guid>
		<description>&lt;humor&gt;
com on lets call it what it really is.  It is a file system 
manager that has a rich text editor.
&lt;/humor&gt;

I will say that VS 2008 seems perform better than its predecessors but it is still bloat ware.</description>
		<content:encoded><![CDATA[<p><humor><br />
com on lets call it what it really is.  It is a file system<br />
manager that has a rich text editor.<br />
</humor></p>
<p>I will say that VS 2008 seems perform better than its predecessors but it is still bloat ware.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Please contribute to Team Hanselman&#8217;s Diabetes Walk 2007 by kim</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/10/07/please-contribute-to-team-hanselman-s-diabetes-walk-2007/#comment-29</link>
		<dc:creator>kim</dc:creator>
		<pubDate>Fri, 19 Oct 2007 14:05:46 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/10/07/please-contribute-to-team-hanselman-s-diabetes-walk-2007.aspx#comment-29</guid>
		<description>This blog&#039;s information is very rich.i very like it</description>
		<content:encoded><![CDATA[<p>This blog&#8217;s information is very rich.i very like it</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The &quot;Domain Model&quot; by Nelson Montalvo</title>
		<link>http://lostechies.com/nelsonmontalvo/2007/09/27/the-quot-domain-model-quot/#comment-28</link>
		<dc:creator>Nelson Montalvo</dc:creator>
		<pubDate>Fri, 28 Sep 2007 00:21:10 +0000</pubDate>
		<guid isPermaLink="false">/blogs/nelson_montalvo/archive/2007/09/26/the-quot-domain-model-quot.aspx#comment-28</guid>
		<description>Makes sense to me. Thanks!</description>
		<content:encoded><![CDATA[<p>Makes sense to me. Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
