#1 2019-11-19 05:48:04

larand54
Member
Registered: 2018-12-25
Posts: 96

Legacy tables and the ID-field

We have a huge system containing several hundreds of tables and I tries to replace pieces of delphi-code by using mORMot and the DDD-concept.
When I do some testing I find that it won't work when the tables don't contain the ID-field. Which is true in most tables.

I can not access these tables without getting the "Invalid column name 'ID'" - error
In the implementation of the service I'm intend not to use ORM on these tables to avoid such problems. But that's not enough.

Even the call of "CreateMissingTables" returns this error. So I wonder if there is a solution for this or if I need to treat these tables in a total different way?


Delphi-11, WIN10

Offline

#2 2019-11-19 09:02:21

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,263
Website

Re: Legacy tables and the ID-field

A genuine 64-bit integer ID is a limitation/feature of SQlite3, and also of mORMot ORM.
So such legacy tables are not compatible with the ORM - unless you add an ID integer additional primary key (which may not be the best idea).

Some hints:
- Write a persistence service as an interface/class (as required by DDD)
- Uncouple persistence and SOA services (i.e. the SOA TSQLRestServer is a TSQLRestServerFullMemory and not a DB/ORM TSQLRestServerDB)
- Reuse your existing SQL statements, with SynDB as access layer if possible (you will have better performance, and direct JSON support)
- You may use the ORM for MicroService local persistence (with SQLite3) - and/or for new tables in your legacy DB (or another storage, e.g. MongoDB)

Offline

Board footer

Powered by FluxBB