DB ORM

Jonas Drewsen jdrewsen at nospam.com
Tue Aug 9 23:38:59 PDT 2011


On 10/08/11 06.47, Kagamin wrote:
> Jonas Drewsen Wrote:
>
>> Just stumbled upon this db orm for c++ that uses the gcc frontend to
>> rewrite c++ code to make classes suitable for database access.
>>
>> http://www.codesynthesis.com/products/odb/
>>
>> They are using pragmas to accomplish this. I guess an equally good
>> implementation in D would use custom attributes for this once (if) they
>> are supported.
>>
>> /Jonas
>
> If there's no mapping, that's bad. A database is a product on its own. It doesn't have to be what you'd like it to be. Objects can correspond to tables quite vaguely. The database may have tricky legacy conventions you don't want to have in your code directly. What about deletion and creation if you have hierarchy of types and objects? What if and object is split between joined tables? Inner joined or left joined.

I'm not sure I understand. Are you against using DB ORMs in general? ORM 
is certainly not a perfect mapping of a database and have plenty of 
shortcomings. Deletion and creation of hierarchies is actually handled 
by some ORMs and there are ways to handle joins as well.

I've not actively used the C++ ORM myself but have been using python 
storm, ruby active record etc. Most of them really makes your code more 
lean and readable. In the special cases where a simple mapping is not 
enough (performance or feature wise) you can always fall back to 
standard SQL queries.

/Jonas


More information about the Digitalmars-d mailing list