You are not logged in.
Pages: 1
Hi,
I am beginning to look at it now and I really liked this very good framework, so I am considering to use it in my project.
But I have some objects that I want to persist in a database whose classes have generic TObjectList<T> properties set in then.
So, would it be possible to use these generic properties with mormot or am I forced to use a simple TObjectList?
Just to show what I mean, look at this little example:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
TExampleClass = class(TSQLRecord);
TMySQLRecordClass = class(TSQLRecord)
private
FMYObjList: TObjectList<TExampleClass>;
procedure SetMYObjList(const Value: TObjectList<TExampleClass>);
published
property MYObjList : TObjectList<TExampleClass> read FMYObjList write SetMYObjList;
end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
I know mormot have compability with many prior delphi versions, But I think it would be great if we could use a generic like this, it would make it easier to implement on my project;
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.
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
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?
Pages: 1