#1 mORMot 1 » How does mORMot handle one-to-many (or many-to-many) relationships? » 2015-07-05 14:01:25

terryc
Replies: 1

I have 2 classes A and B which inherit from a base class C.
A has a collection of B references
B has a reference to A.
These are implemented in my PODO objects as a TCollection (using generics) of B's and as a reference to A (+ some mechanisms to manage auto-updates of the inverse relationships when needed).

When I used the ComputeSQLRecord operation, it got it completely wrong: it implemented the reference to A in B as taking all the direct attributes of A (not the inherited ones from C) and putting them directly in B. Naturally the inherited attributes from C will be different in objects A and B.

Why would it not create an object relationship? Should it be done by hand?

Best regards,
Thierry

#2 Re: mORMot 1 » How to persist a complete domain? » 2015-07-05 00:26:44

Thank you!
Indeed it is much simpler than I thought. The only object to create is the TSQLERestServerFullMemory. The TSQLRestStorageInMemory are not needed, as every operation can directly be performed on the RestServer.

initialization
  Database  :=  TSQLRestServerFullMemory.Create( Model, ChangeFileExt(Application.ExeName,'.json') );
finalization
  FreeAndNil(model);
  Database.ExportServer;
  FreeAndNil(Database); 
end.

and in the application layer:

   objectA:= TSQLRecordA.CreateAndFillPrepare(Database, ''); 
   ...
  Database.Add(objectA, true);

#3 Re: mORMot 1 » mormoti18n does not compile under Lazarus+FPC? » 2015-07-05 00:06:10

So? It seems to me Lazarus + FPC is quite capable of generating Windows code...
There is an i18n implementation on Lazarus.

I would suggest that compiler-specific (aka Delphi) code should be separated from the main mORMot sources. For the moment, it's not possible to distinguish easily what is cross-platform and usable anywhere to what is specific to a given platform and compiler.

BR

#5 Re: mORMot 1 » Is there a TDataset descendent to connect to TSQLRestStorageInMemory? » 2015-07-05 00:02:15

No, I don't think TBufDataset should know about mORMot's TSQLRest, particularly in the InMemory version. I'll try to set up a clear test case.
BR

#6 mORMot 1 » Is there a TDataset descendent to connect to TSQLRestStorageInMemory? » 2015-07-04 09:40:35

terryc
Replies: 5

Hello,
i'm sorry to ask all these questions, but i'm trying to get into mORMot.

So is there a TDataset descendent to connect to TSQLRestStorageInMemory? ( a full one, not a read only version).
I would like to connect the TSQLRecord objects to the Lazarus GUI with TDataset.

Best regards,
Thierry

#7 Re: mORMot 1 » How to persist a complete domain? » 2015-07-04 09:02:11

OK, i tried with TSQLRestServerFullMemory, using the following code in initialisation and finalisation:
Without the filename in the tableclient for class A, the database is not saved,
With the filename in the table client for class A, it is stored in its particular file, not the general file for the whole database.
What am I missing?

initialization
  Database  :=  TSQLRestServerFullMemory.Create( Model, ChangeFileExt(Application.ExeName,'.json') );
  gTableA    :=  TSQLRestStorageInMemory.Create( TSQLA, Database, ChangeFileExt(Application.ExeName,'.A.json'));
  gTableB    :=  TSQLRestStorageInMemory.Create( TSQLB, Database, ChangeFileExt(Application.ExeName,'.B.json'));
finalization
 FreeAndNil(model);
  FreeAndNil(gTableA);
  FreeAndNil(gTableB);
  Database.ExportServer;
  FreeAndNil(Database); 
end.

#8 mORMot 1 » Is there another way to generate the RTTI? » 2015-07-04 08:12:24

terryc
Replies: 2

if one DOES NOT have Delphi.

Sorry, i'm using exclusively Lazarus+FPC. Ditched Delphi years ago and don't have any of it anymore.

So, is there any other way to generate the interfaces?

I saw the interfaces RTTI patch was nearing completion, but it's still not there...

I saw RTFM 25.4.2, but there's no example of the generated code, so i don't know what to write.
Would it be possible to post a couple of examples with the typical generated code?

Thanks.

Best regards,
Thierry

#9 Re: mORMot 1 » How to persist a complete domain? » 2015-07-04 08:04:26

Thank you very much. I will try that.

I would suggest ComputeSQLRecord does not duplicate the code for the ancestor classes, if they are common.

Best regards,
Thierry

#10 Re: mORMot 1 » Is there a Lazarus port of the MainDemo? » 2015-07-04 08:02:52

Hi
for the moment, this is valid only under windows, i used the TMetafile defined in EPANET2Lazarus, maded by lfrodrigues.
Obviously, i haven't been able to test, since the compiler had errors further down.

Best regards
Thierry

#11 mORMot 1 » mormoti18n does not compile under Lazarus+FPC? » 2015-07-04 07:59:36

terryc
Replies: 2

Line 893 does not compile:
"if ResStringRec.Identifier<64*1024 then begin"

with message "mORMoti18n.pas(893,19) Error: Illegal qualifier"

There are many others like this one.

Is there a compiler option i should set?

Environment: Lazarus + FPC 2.7.1

#12 Re: mORMot 1 » How to persist a complete domain? » 2015-07-04 04:54:11

Creating a complete model:
  SomeModel = TSQModel.Create([Set of SQL classes]) //Not domain classes, SQL classes.

Creating the client database (as in client/server):
  Client :=  TSQLRestClientDB.Create(ClientModel, ServerModel, ChangeFileExt(Application.ExeName,'.db3'), TSQLRestServerDB);

Populating the tables (if missing or needed to update):
  TSQLRestClientDB(globalClient).Server.CreateMissingTables(0);

This works in Lazarus + FPC 2.7.1

#13 mORMot 1 » Is there a Lazarus port of the MainDemo? » 2015-07-04 04:50:30

terryc
Replies: 2

Hello,
is there a Lazarus port of the MainDemo?

It does not compile under FPC: most of the graphical units in mORMot don't compile.
I found a replacement for TMetafile but then the compiler raised an error just a few steps further.

#14 mORMot 1 » How to persist a complete domain? » 2015-07-04 03:03:17

terryc
Replies: 6

Hello,
Imagine there are several classes in a domain:
A <- B <-C
    <- D
    <- E

Where D has a reference to C and E has a reference to D.

For example, how can one create a simple in-memory database? There are several issues i don't understand:
- TDDDRepositoryRestFactory.ComputeSQLRecord([C, D, E]) creates several duplicates (on all common ancestors). OK, i can remove the duplicates, but i would expect the operation to be able to identify the common ancestors.
- then TSQLRestStorageInMemory.Create takes only a single class as a parameter ???

How can the whole domain be persisted?

In a real application, there would be many domain classes, broken down in sub-domains.

FYI Environment : Lazarus/FPC 2.7.1. No Delphi environment.

#15 Re: mORMot 1 » How does mORMot handle DDD model upgrade? » 2015-07-04 01:09:28

Further information: The exception raised is in mormot.pas, class EORMException, TSQLPropInfoRTTI.CreateForm: Unhandled stfFloat/tkFloat type for property Number.

Does mORMot actually handle the extended type?

#16 mORMot 1 » How does mORMot handle DDD model upgrade? » 2015-07-04 00:51:28

terryc
Replies: 2

Hello,
How does mORMot handle the DDD upgrade? (adding new classes, attributes, associations, or removing same on an existing and in-use model?)

For example, in the basic 01-In Memory ORM demo,
- I compiled the basic demo, ran it a few times, added a few examples and quit, This worked perfectly, data is stored and retrieved. Nice.
- I then added one Number field with the TSynExtended type to the TSQLSampleRecord in the unit SampleData. Compiled. OK.
- I ran the resulting application. And it crashed with an External Sigsegv.

I'm using a form of Agile, and i would expect upwards-compatible modifications to the DDD to be accepted by the ORM. How can i do that?
I do have the capability to track and identify the model changes, if specific actions need to be perform to update the repository.

I'm using Lazarus with FPC 2.7.1.

Thank you for your help.
Best regards,
Thierry

Board footer

Powered by FluxBB