- This topic has 2 replies, 2 voices, and was last updated 6 years, 7 months ago by .
Viewing 2 reply threads
Viewing 2 reply threads
- You must be logged in to reply to this topic.
Hi,
In my application I make use of composite objects in combination with the ORM for instance a TPerson having a TAddress property. Which I will use like this:
Person := ORM.Query<TPerson>([1]);
Person.Address := ORM.Query<TAddress>([1]);
Thanks in advance!
Say:
TPerson = class
…
FAddress:TAddress;
end;
A person could exist without an address, why Address having the value of nil is a valid situation. Hence you should generally not instantiate an Address instance unless you absolutely know a Person have an address.
So you assumption is correct.
Im not sure CreateWithComposites would be a good idea, because how will it know exactly which composites to instantiate with an empty, but instantiated value, and which not to. Further having an instantiated but empty address does also “logically” make sense. Either you have an address or at least a tentative address (because you are about to fill it out) or you dont. In the later case, Address ought to be nil.
QueryList returns a TObjectList<TYourclass>.
kbmMW however checks if it needs to instantiate a new list or if a list already exists. In the later case, it will reuse that one.
Typo:
Further having an instantiated but empty address does also “logically” not make sense.