<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Examples of O/R Mapping vs Stored Procedures</title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx</link><description>Mike Schinkel of Xtras.net responded to my previous post about "dynamic sql" by asking for a real-world comparison "example" that would clearly demonstrate the pros and cons of O/R Mapping. I seriously thought about providing such an "example" for a few</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>O/R Mapping (Object/Relational Mapping) </title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#7136831</link><pubDate>Mon, 29 Jun 2009 22:19:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7136831</guid><dc:creator>rbfigueira</dc:creator><author>rbfigueira</author><description>&lt;p&gt;Quem &amp;#233; que ainda n&amp;#227;o conhece o NHibernate , LLBLGen Pro entre outros ? Como sabem estas &amp;amp;quot;tools&amp;amp;quot;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7136831" width="1" height="1"&gt;</description></item><item><title>O/R Mapping (Object/Relational Mapping) </title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#7136039</link><pubDate>Sun, 28 Jun 2009 20:09:55 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7136039</guid><dc:creator>rbfigueira</dc:creator><author>rbfigueira</author><description>&lt;p&gt;Quem &amp;#233; que ainda n&amp;#227;o conhece o NHibernate , LLBLGen Pro entre outros ? Como sabem estas &amp;amp;quot;tools&amp;amp;quot;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7136039" width="1" height="1"&gt;</description></item><item><title>O/R Mapping (Object/Relational Mapping) </title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#7120923</link><pubDate>Sat, 13 Jun 2009 20:13:41 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7120923</guid><dc:creator>rbfigueira</dc:creator><author>rbfigueira</author><description>&lt;p&gt;Quem &amp;#233; que ainda n&amp;#227;o conhece o NHibernate , LLBLGen Pro entre outros ? Como sabem estas &amp;amp;quot;tools&amp;amp;quot;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7120923" width="1" height="1"&gt;</description></item><item><title>O/R Mapping (Object/Relational Mapping) </title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#352201</link><pubDate>Thu, 13 Jan 2005 16:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:352201</guid><dc:creator>TrackBack</dc:creator><author>TrackBack</author><description>&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=352201" width="1" height="1"&gt;</description></item><item><title>re: Examples of O/R Mapping vs Stored Procedures</title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#242187</link><pubDate>Thu, 14 Oct 2004 08:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:242187</guid><dc:creator>Christian Braun</dc:creator><author>Christian Braun</author><description>Wow that was pretty fast, thx a lot Paul!&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=242187" width="1" height="1"&gt;</description></item><item><title>re: Examples of O/R Mapping vs Stored Procedures</title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#242057</link><pubDate>Thu, 14 Oct 2004 00:34:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:242057</guid><dc:creator>Paul Wilson</dc:creator><author>Paul Wilson</author><description>Martin Fowler's &amp;quot;Patterns of Enterprise Application Architecture&amp;quot; is good background.&lt;br&gt;&lt;br&gt;Christian Bauer and Gavin King's &amp;quot;Hibernate in Action&amp;quot; is the best practical example book.&lt;br&gt;&lt;br&gt;Scott Ambler at &amp;quot;&lt;a target="_new" href="http://ambysoft.com/mappingObjects.html&amp;quot;"&gt;http://ambysoft.com/mappingObjects.html&amp;quot;&lt;/a&gt; has a fair amount of information online.&lt;br&gt;&lt;br&gt;Other online resources are &amp;quot;&lt;a target="_new" href="http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm&amp;quot;"&gt;http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm&amp;quot;&lt;/a&gt;&lt;br&gt;and &amp;quot;&lt;a target="_new" href="http://www.joeyoder.com/Research/objectmappings/&amp;quot;"&gt;http://www.joeyoder.com/Research/objectmappings/&amp;quot;&lt;/a&gt;&lt;br&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=242057" width="1" height="1"&gt;</description></item><item><title>re: Examples of O/R Mapping vs Stored Procedures</title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#242041</link><pubDate>Wed, 13 Oct 2004 23:48:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:242041</guid><dc:creator>Christian Braun</dc:creator><author>Christian Braun</author><description>Hi there, &lt;br&gt;&lt;br&gt;just yesterday i started my master thesis about o/r mappers. Can anyone of u give me a hint for good theories about that stuff? I really need 2 learn that stuff from the beginning, any good books would be great. &lt;br&gt;My main thesis will be about the pros and cons of O/R Mapping, perfomance and testing/describing some tools... &lt;br&gt;For any information, links and book tips i will be most grateful. &lt;br&gt;&lt;br&gt;Best regards Christian &lt;br&gt;&lt;br&gt;Excuse my bad english, i am german and not that used to it, sorry.&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=242041" width="1" height="1"&gt;</description></item><item><title>re: Examples of O/R Mapping vs Stored Procedures</title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#238527</link><pubDate>Wed, 06 Oct 2004 08:27:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:238527</guid><dc:creator>Dennis v/d Stelt</dc:creator><author>Dennis v/d Stelt</author><description>Also another good reason NOT to use SP's is that most people put _so_ much functionality in SP's that they most of the time would not do in dynamiq-inline-sql statements (parameterised of course). I just came on a project where sp's are calling sp's and have lots of if's and way more.&lt;br&gt;&lt;br&gt;Some freezing is done with a datetime as parameter. SQL functionality is used to get the last day of the previous month and that date is used as parameter for other SP's. But what if something goes wrong and you have to get the last day-of-the-month for 3 months ago? Then you have to rewrite the SP's or do everything manually. Just a simple example of things that can go very wrong with SP's because you're possible to do. I can only fear of what to expect once we can use .NET code in SQL2005!&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=238527" width="1" height="1"&gt;</description></item><item><title>re: Examples of O/R Mapping vs Stored Procedures</title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#232586</link><pubDate>Tue, 21 Sep 2004 22:15:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:232586</guid><dc:creator>Jeff Gonzalez</dc:creator><author>Jeff Gonzalez</author><description>Thanks for the information, we are using method #2 ourselves, but relying on cleaning data always makes me feel...dirty.&lt;br&gt;&lt;br&gt;I guess you can probably account for 99.999% of attacks that way and that small 0.001% chance isn't enough benefit for the cost it takes to secure it. &lt;br&gt;&lt;br&gt;Security and Flexibility always seem to be in direct contradiction of each other.&lt;br&gt;&lt;br&gt;Thanks for the information&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=232586" width="1" height="1"&gt;</description></item><item><title>re: Examples of O/R Mapping vs Stored Procedures</title><link>http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx#232557</link><pubDate>Tue, 21 Sep 2004 20:59:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:232557</guid><dc:creator>Paul Wilson</dc:creator><author>Paul Wilson</author><description>First, all of my mapper's persistence is parameterized.  Next, there are several ways that you can retrieve data -- and the option you choose can certainly impact whether there is any/much potential for sql injection.  &lt;br&gt;&lt;br&gt;(1) The simplest method is to just create all your own where-clauses -- I try NOT to do this in any of my examples since it obviously leaves the developer entirely responsible for &amp;quot;cleaning&amp;quot; all entered data.  &lt;br&gt;&lt;br&gt;(2) The next method, which is what I almost always use, is to build your where-clauses with my QueryHelper methods.  This makes it easy to build &amp;quot;clean&amp;quot; equality expressions, as well as allowing you to not have to know the table and field names, or your databases delimiters.  There is also a very good OPath syntax parser that can help you build other &amp;quot;clean&amp;quot; expressions in most cases.  I find using the QueryHelper prevents nearly all sql injection, if not all, but I can't of course make any such 100% guarantee either, especially when multiple types of databases are involved.&lt;br&gt;&lt;br&gt;(3) The final technique is to build the entire sql select statement with paramaters, and then use the overrides with the SelectProcedure class instead.  This allows you to do all retrieval with parameterized sql, but it does require more work, so I don't typically do this since I believe the other solution good enough.  Note that you can still even in this case use the QueryHelper to get your table and field names, although the rest would be up to the developer.&lt;br&gt;&lt;br&gt;As for &amp;quot;Order By&amp;quot;, the QueryHelper can again be used to validate field names, but certainly there is room for developers to not &amp;quot;clean&amp;quot; sort parameters entered by users.&lt;br&gt;&lt;br&gt;In the end, I think my mapper has all the capabilities of being safe against sql injection, but there are certainly also capabilities for developers to do things poorly.  So developers should still make sure that anything entered by the user (including querystrings) is properly &amp;quot;cleaned&amp;quot;, and its also true that your databases should still be properly secured.  Yes, its true that you need to allow read and write roles in your database for your application, but you can (1) not use sa or give ddl permissions and (2) secure your application correctly from unauthorized attacks.  An ORMapper is a very good tool, but that's all it is -- one tool of hopefully many others in your toolbelt -- it should not be an excuse to be ignorant and/or lazy.&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=232557" width="1" height="1"&gt;</description></item></channel></rss>