Fog Creek Software
Discussion Board

Database to object mapper

So I am reading Fowler's "Patterns of Enterprise Application Architecture." and he states:

"Remember that you don't have to build a full-featured database-mapping layer.  It's a complicated beast to build, and there are products available that do this for you."

With this in mind, I spent a fruitless hour or so searching for this software, but I just can't find the buzzwords to get google to spit out some.

Can any of you kind people throw me in the right direction?



P.S. And to all of you angry ones who hate my “inane” posts, just hit back and find another article.  Better yet, go to and take a chill pill!

Friday, May 30, 2003


Look into "Typed Datasets"

For non-MSian solutions, try searching database+class+generator

However, I'd say before investing any $$$, look at how maintainable the produced code is. There are two viable routes, IMHO:
1) Easy to modify code
2) Easy to generate code

With (1), when you add a column or change a table def, you just "fix" the class with a bit of typing. With (2), the tool is so robust and easy to use, you simply regenerate the class.


Friday, May 30, 2003

In Java, I recommend



In Perl, take a look at SPOPS

(all open source)

Friday, May 30, 2003

This is something I've been curious about as well. Does anybody have anything in the C++ vein? Preferably non-MS.


Friday, May 30, 2003

The type of product you're looking for is an "object/relational mapper", sometimes called "O/R mapper".

Brad Wilson (
Friday, May 30, 2003

In the Delphi world I'm sure the Bold Framework that comes with Delphi 7 Architect includes an integral O/R mapper.  That binds you to working with the entire Bold framework, though, I would guess.

There's also an open source Delphi object persistence framework called tiOPF:

And an inexpensive framework, kind of a Bold-lite, called "InstantObjects Object Persistence Framework":

Herbert Sitz
Friday, May 30, 2003

Will: thanks for the SPOPS props!

The OP might also be interested in a collection of other O/R mapping tools in Perl [1]. This is one of the areas where no matter what language you're using there're more than one way to do it...


Chris Winters
Friday, May 30, 2003

Not an available framework itself, but here's a link to Scott Ambler's white paper "The Design of a Robust Persistence Layer for Relational Databases":

Herbert Sitz
Friday, May 30, 2003

Good products understandable for mere mortals and which work well: for .NET (I sell it, there is a sample PetMarché app in 800 lines of code, compare this to Java where you have an increase of an order of magnitude) -DataBinding is supported. This product is based on the paper from Scott Ambler. It does VB6, VB.NET and C# going to SQLServer or Access. The Access version is free. for a Java mapper w/ XML configuration. (free) for a Java mapper to a database (no XML, no funky generator, the defs are in the code) (free and I use it).

Philippe Back
Friday, May 30, 2003

A few weeks ago, I wanted to wrap a bunch of SQL Server stored procedures with ADO and VBScript. 

It literally took me a matter of minutes to throw together the code to query the system tables and generate the wrappers -- much less time than what I spent before that trying to find one that has already been written. 

The following query (tested in SQL Server 2000) will return a recordset listing information for all the columns in user tables in the current database (it'll probably turn out messy from the formating, but you'll get the idea):

SELECT AS 'Table', AS 'Column', AS 'Type',
    col.length AS 'Length'
    FROM sysobjects obj
    JOIN syscolumns col ON
    JOIN systypes type ON col.xtype = type.xtype
    WHERE obj.type='U'
    ORDER BY, col.colorder

It's trivial to iterate through this recordset to generate wrapper code.  I imagine non-MS systems offer similar access to metadata.

Friday, May 30, 2003

TOPLink - I believe there is a C++ version as well as Java versions.

In the Java world you've got TOPLink (and similar products), the Java Data Objects spec (inspiried by TOPLink) and CMP entity beans all providing persistence mechanisms that free developers from thinking in terms of SQL.

TOPLink - looks like TOPLink was sold to Oracle (their J2EE suite comes with TOPLink;, unsure about the status of the C++ version given this (change the "is" above to "was").

JDO - (possibly some of the providers have C++ products too)

Walter Rumsby
Friday, May 30, 2003

*  Recent Topics

*  Fog Creek Home