Polymorphism in SingleTable Stategy

As described in Docs
Aurelius allows polymorphism.

Regarding Mapping Examples, it looks like it's working for Joined-Tables.

if I would like to put AbstractEntities within SingleTable, strategie, how can I do it?

For Example:

[Entity]
[DiscriminatorColumn('Type', TDiscriminatorType.dtString)]
TFiles = class...

[AbstractEntity]
TImages = class(TFiles)...

[Entity]
[DiscriminatorValue('JPEG')]
TJPEG = class(TImages )...

[Entity]
[DiscriminatorValue('GIF')]
TGIF = class(TImages )...

Building the Model, it raises "Class TImages is not a valid Entity." ...

It works, if TImages has Attribute [Entity] as described in exception, but I don't want TImages to be instantiable at all.

Also TImages provides some Fields, that are not provided to the TFiles-Table.

1 Like

You can't. Abstract entities is not intended for that. Abstract entities are Delphi classes that are not Aurelius entities which define some mapping abstracts that will be "inherited" by any Aurelius entity class that inherits from such abstract class.

But once your hierarchy "becomes" an Aurelius real entity, you cannot have more abstract entities in that hierarchy.

ok, understood.

So I'll implement TImages as class abstract(TFiles),
so that nobody would try to instantiate this. But it has to be a [Entity], so the inheritance would work.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.