Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Object Persistence...(to a database)

I'm not sure if anyone's considered this, so I'm just throwing this out there for ideas, feedback, etc..

I really hate dealing with creating database tables, columns, etc, then having to create classes for each table/record-type and then the ensuing CRUD operations.  Now I know that there are quite a few O/R Mappers out there, but again, I don't want to have to deal with any of the database tools stuff when I'm building an app.  Nor do I want to define my schema in an XML file and have it generate the database schema at runtime, etc.  In theory, I'd like to do this via an attribute-based system.

So in my world, I'd have a EntityClassAttribute that defines the entity's database identifier (name, unique id, etc) & table name (this way you can use multiple databases in the same app.) 

Then for whichever properties I'd want to persist to the database, I would assign an EntityPropertyAttribute, defining the column name, its System.Data.DbType, if it's a primary key, its default value, etc.  I'm sure I would add some type of EntityForeignKeyPropertyAttribute as well. 

Now, at runtime (first-time startup or during debugging, every-startup), the EntityEngineFactory would return a EntityEngine for the database server being used (SQL Server, MySQL, MaxDB, etc) that would incorporate each server's unique syntax, etc.  Using reflection, it would look at all classes having the EntityClassAttribute attribute and their corresponding EntityPropertyAttribute(s) and generate the tables, columns, CRUD stored procs.  While working with instances types having the EntityClassAttribute, you would call EntityEngine.Save(theInstance) and it would already know how to persist it...

Am I barking up the wrong tree?  I just want to make sure this is a sane idea.  I just want to most of my work in the IDE, in C#.  Ideas, Feedback, etc welcome!

GiorgioG
Sunday, February 20, 2005

Bark!

Sgt.Sausage
Sunday, February 20, 2005

I think object persistence is going to become part of VS 2005.

Colm O'Connor
Monday, February 21, 2005

Actually it's slated to be available for download "sometime after" VS.NET 2005 is released.

GiorgioG
Monday, February 21, 2005

Yeah this is an idea I heard before. In the java world there are tool that use XDoclets for exatly that. I beleive in .NET NHibernate (the maybe most common used OR Mapper tool) has this on its roadmap.

Of course you could implement this on your own and contribute your tool to the NHibernate project. I would certainly use it!

Joe
Thursday, February 24, 2005

http://nhibernate.sourceforge.net/
NHibernateContrib - 0.6.0.0 added NHibernate.Tool.Net2Hbm that enables classes to be mapped with Attributes instead of hbm.xml files - contributed by John Morris.

http://www.mertner.com/confluence/display/Gentle/Documentation+Home
The framework defines a few attributes with which you have to decorate the objects you wish to persist.

Nas
Friday, February 25, 2005

Take a look at this :

http://www.borland.com/delphi/architect/eco/

New Borland® Enterprise Core Objects II (ECO™ II) rapid design-driven architecture for .NET speeds development, improves quality, and increases the maintainability of complex Web Services, ASP.NET, and WinForm applications. Architects can use the model-powered ECO Object/Relational Mapping technology to generate or map to several major enterprise-class relational databases, then later evolve the database based on changes in the design model. Build enterprise-level model-powered applications using the new ECO Synchronization Server, offering multiple synchronized ECO Space object caches for increased scalability and performance.

The following tutorials will take you step-by-step through building a variety of ECO applications.

    * Tutorial 1: Creating your first ECO application
      This article demonstrates building a simple application using the Borland Enterprise Core Objects (ECO)™ technology in Delphi 2005 Architect.
    * Tutorial 2: Working with Associations
      This article demonstrates accessing Borland ECO™ objects in code via handles, implementing relationships and using master/detail style user interfaces.
    * Tutorial 3: Using ECO™ II with Databases
      This article demonstrates connecting an ECO™ application to a RDBMS and managing changes to the object space.
    * Tutorial 4: Using an existing enterprise database with Borland® ECO™ II and Borland Delphi® 2005
      This paper provides step-by-step instructions on how to promote an existing relational database, including existing data, and how to provide a Unified Modeling Language™ (UML®) class diagram representation of this.

Part 1: Deriving a model from an existing database with ECO II in Delphi 2005
The following demonstrates how ECO II in Delphi 2005 can produce a model from an existing database, and immediately use that model as part of a model-powered application. The resulting application is a C# Winforms application that uses the Northwinds database as the source of its model. [Time: 9:39]

http://dotnet.borland.com/bdntv/delphi/eco2modelderivation.html

DelphiGuru
Wednesday, March 30, 2005

*  Recent Topics

*  Fog Creek Home