You are not logged in.
Pages: 1
Hello,
I'm reading the book of Erick about mORMot trying to understand the conecept of the ORM/DDD/Aggregate: I understand that is doesn't 'join' table as I thought firstly but it's technology or a way for representing your data as DDD/ORM.
Erick show an example in page 183 but when I run that code the 'pTree' field in 'plant' table is 'bigint' not json as showed in Erick book, can someone tell why?
Erick's table:
Erick says : "The descendant classes are technically stored as JSON, and when you read them, they are retrieved and de-serialized back to the structured format."
TTree = class(TSQLRecord)
private
fnumTreeHouses: integer;
frequireleafpickup: TDate;
published
property tNumTreeHouses: integer read fnumTreeHouses write fnumTreeHouses;
property trequireleafpickup: TDate read frequireleafpickup write frequireleafpickup;
end;
TPlant = class(TSQLRecord)
private
fType: RawUTF8;
fheight: integer; // cm or inches
fleafcolor: integer;
fTree : TTree;
published
property pType: RawUTF8 index 20 read fType write fType stored AS_UNIQUE;
property pHeight: integer read fheight write fheight;
property pLeafColor: integer read fleafcolor write fleafcolor;
property pTree : TTree read ftree write ftree;
end;
....
Plant, plant2 : TPlant;
aServerName:= TSQLDBZeosConnectionProperties.URI(dMySQL,aRawServerName);
Model:= TSQLModel.Create([TTree,TPlant],ROOT_NAME);
props:=propsClass.Create(aServerName,aDatabaseName,aUserID,aPassword);
VirtualTableExternalRegister(Model,TPlant,props);
VirtualTableExternalRegister(Model,TTree,props);
// save aggregate root
plant := TPlant.Create(DB,'');
plant.pType := 'oak';
plant.pTree := TTree.Create;
plant.pTree.fnumTreeHouses := 1;
plant.pTree.frequireleafpickup := now;
DB.Add( plant, True);
plant.pTree.Free;
plant.Free;
Last edited by mhmda (2017-08-27 08:59:07)
Offline
I understand now, Thank you ab and I think Erick should correct that in his book.
Offline
Pages: 1