#1 2015-07-05 14:01:25

terryc
Member
Registered: 2015-07-04
Posts: 16

How does mORMot handle one-to-many (or many-to-many) relationships?

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

Offline

#2 2015-07-05 14:32:31

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

Re: How does mORMot handle one-to-many (or many-to-many) relationships?

I never used TCollection + generics with mORMot.
So perhaps there is an issue about this kind of classes.

The PODO in mORMotDDD.pas are expected to be plain aggregates, i.e. with NO direct relationship.
See http://martinfowler.com/bliki/Aggregate.html
and http://synopse.info/files/html/Synopse% … l#TITL_124
and http://synopse.info/files/html/Synopse% … ml#TITL_29

Lists are natively stored as T*ObjArray in mORMotDDD.pas.

But perhaps this is not your problem, and I've not understood your issue.

Offline

Board footer

Powered by FluxBB