You are not logged in.
Pages: 1
I have two classes, which need to be persisted in a database;
say, TFolha and TFolhaEntradas.
example:
TFolhaEntradas = class (TSQLRecord)
published
property example: String;
end;
TFolha = class (TSQLRecord)
published
property FolhaEntradas: TObjectList <TFolhaEntradas>;
end;
I read in the documentation, that mORMmot keeps the OBJECTList as Json, is that correct?
I need that each objects of the TObjectList <TFolhaEntradas> may be stored in the table of the class TFolhaEntradas!
How could it be done?
Last edited by mORMotStudent (2018-01-04 13:11:07)
Offline
I am looking for a good ORM solution to adopt in a new project, and i think mORMot would be a good candidate, but I am looking for some new basic information about it;
This post (https://synopse.info/forum/viewtopic.php?id=1073)
almost answered my question. That post is about ONE to ONE relation.
but how do mORMot deal with a "one to Many" relation? How does it work in the database?
Does it just create a blob with JSON objects, or create real relations in the database?
Thank you
Offline
Did you Read this docs? https://synopse.info/files/html/Synopse … ml#TITL_70
Offline
Thank you, for the reply. I just started to read and test this framework;
After reading the section you suggested, I am trying to use the TSQLRecordMany to get the relationship between the two tables; If I am understanding correctly, it uses a pivot table to do it.
I will use here a simple example, what I want is to understand the correct way to get this relationship working;
So I created three classes, to make the tests.
TPerson(TSQLRecord)
TPhone(TSQLRecord) and
TPhones(TSQLRecordMany)
Then I created a published property in TPerson like this:
property Phones: TPhones read FPhones write FPhones; //TPhones is descending from TSQLRecordMany
But when I use this procedure of TPerson:
procedure TPerson.InsertPhone(IDDI,IDDD,INumber : Integer) ;
var phone : TPhone;
begin
Phone:= TPhone.Create;
Phone.ddi := Iddi;
Phone.ddd := Iddd;
Phone.numero := INumber ;
if Telefones.ManyAdd(Database.client,self.ID,phone.ID,true,nil) then ////This Method ManyAdd is failing, (returning false)
showMessage('Method returned true') else
showMessage('Method returned false');
end;
So, what is the correct way to use it?
======================================
If I use a TObjectList as a property in a TSQLRecord class, I get a blob JSON in the database table, but what I want is each of these objects may be stored inside its own table, and not as a blob field.
Last edited by mORMotStudent (2018-01-08 03:21:43)
Offline
Pages: 1