Andrew Stopford's Weblog

poobah

Sponsors

News

Articles

Family

Old Blogs

O/R mappers/Sprocs

I was looking at the various the O/R mappers and considering how they fit into using stored procedures, I am still not clear on the answer and indeed if a O/R mapper should be considered if using sprocs. If a O/R was to map out queries that would normally be inside a sproc then would peformance decrease? Your thoughts, advice/mileage on this welcome.
Posted: Aug 23 2006, 10:50 PM by astopford | with 13 comment(s)
Filed under:

Comments

Travis said:

I simply dont use sprocs anymore.  With a good OrMapper, you dont need them. That is a layer I dont have to *deal* with anymore in my apps.

Now there are arguments that have been re-hashed a billion times, but in the end the OrMapper's benefits out weigh sprocs by far. I wont argue sprocs do have some benefits.

Also there are some OrMappers that can use sprocs, http://www.ormapper.net comes to mind for the best of both worlds.

# August 23, 2006 6:02 PM

Andrew Stopford said:

This post by Paul Wilson is interesting - http://weblogs.asp.net/pwilson/archive/2004/09/18/231188.aspx

but in a real world query what about several tables with several joins or variables from one table to serve another query etc?

# August 23, 2006 7:07 PM

Mike Gale said:

Depends what you're doing.

If it's pure CRUD, where your OO and the relational model have clear correspondence there's one answer.

If the sprocs do some relational work that will take a lot of OO code to emulate it's another.

Neither is there a good reason for an OR-mapper not to encapsulate sprocs!

I feel the real problem is languages that have big blind spots.  (Think C# vs. T-SQL for example.)  COmega looked on the surface to have a much smarter language design, though we won't (unfortunately) see all of that any time soon.

To repeat.  It depends what you're doing (and how things are architected).

# August 23, 2006 7:45 PM

sean said:

nhibernate... kickass...

# August 23, 2006 11:09 PM

Matt Smith said:

I agree with Travis. We use LLBL Gen Pro (http://www.llblgen.com) on our site (http://www.myhomepoint.com) and it is great to leave the majority of our DAL up to the O/R mapper. Occasionally we've had to go outside of it, but he includes strongly typed methods for calling sprocs.

# August 23, 2006 11:11 PM

Ayende Rahien said:

One of the major source of power for most ORM is that they have a great amount of flexibility in generating SQL.

SP limit you to a predetermained set of operations, often very hard to handle.

If you need do present a different view to the world than your real tables, use views.

# August 24, 2006 12:59 AM

Udi Dahan - The Software Simplist said:

The place where I still use SPs for even when using an O/R mapper is for triggers - especially in cases of updatable views.

After doing O/R mapping for quite some time now, I have found that updatable views are a required abstraction. On the one hand, you want to allow the DBA (sometimes myself) to reorganize or partition tables (for example horizontally) for improved performance, while on the other hand you don't want to have to redo all the mapping work. Views give you just what you need.

# August 24, 2006 2:09 AM

Andrew Stopford's Weblog said:

In my last post I pondered for how a ORM and Sprocs fitted in, for mea database that is in at least 4nf

# August 24, 2006 5:24 AM

Sarah said:

O/R mapping tools are becoming more popular each day and people are realizing the productivity gain they provide to developers. Yet, many people don’t know enough about O/R mapping to consider using these tools and many others are weary of using any code generators (including O/R mapping tools).

In this article, Iqbal Khan try to educate people about the various important features that a good O/R mapping tool would provide us and how it can be beneficial to us.

# August 24, 2006 7:06 AM

Sarah said:

O/R mapping tools are becoming more popular each day and people are realizing the productivity gain they provide to developers. Yet, many people don’t know enough about O/R mapping to consider using these tools and many others are weary of using any code generators (including O/R mapping tools).

# August 24, 2006 7:07 AM

Wim Hollebrandse said:

I've written a CodeSmith template which along with data access entities generates the sprocs for me, and have integrated this step into the VS.NEt 2003 build using Nant.

# August 24, 2006 8:49 AM

David Parslow said:

Sprocs != bad

O/R Mappers can work with sprocs to generate a strongly typed result (O/R Mapping) of the sproc as well as make the sproc look more like a function in that the syntax you call the sproc is also strongly typed.

# August 24, 2006 7:02 PM

bonder said:

The best OR/Ms let you use sprocs where you want to and entities and collections everywhere else.

I've used LLBLGen Pro generate a DAL included storngly-typed stored procedure calls that enabled my team to start out by calling all of our legacy procs, and then deciding where to refactor to entities and collections.  That was years ago, and today that project still have some procs, but they just turned out to be not productive use of anyone's time to refactor (and in one case, would not have been performant to do so).

I'm now looking at SubSonic which does everything through ASP.Net 2.0 build providers to produce the OR/M objects at build and run.  This cuts down generated DAL code to ZERO (although there is a utility to generate the classes for you since you can't use build providers in medium trust by default).

# September 9, 2006 4:18 PM