In 5.11 you gave us functionality of using Associations in AbstractEntities.
Now I'm trying to use ManyValuedAssociations in AbstractEntities. Looks like, this is not supported right now.
I got
Class ... is not a valid Entity. [Entity] attribute missing or entity does not belong to model.
wlandgraf
(Wagner Landgraf)
March 28, 2023, 4:42pm
2
How are your mapping and the error message, exactly? You can add a ManyValuedAssociation
attribute to an abstract entity, but the associated entity can't be abstract. This is valid for both associations and many-valued associations.
I got this EInvalidEntity-Exception:
Error mapping entity type Entities.TAbstractEntity: Class TAbstractEntity is not a valid Entity. [Entity] attribute missing or entity does not belong to model. (EInvalidEntity)
This is my EntityMapping out of my Demo-Project:
[AbstractEntity, Automapping]
TAbstractEntity = class abstract
private
FId: Integer;
[ManyValuedAssociation([], CascadeTypeAllRemoveOrphan)]
FChild: TList<TChild>;
public
constructor Create;
destructor Destroy; override;
property Id: Integer read FId write FId;
property Child: TList<TChild> read FChild write FChild;
end;
[Entity, Automapping]
TEntityOne = class(TAbstractEntity)
private
FDummy: string;
public
property Dummy: string read FDummy write FDummy;
end;
[Entity, Automapping]
TEntityTwo = class(TAbstractEntity)
private
FDummyTwo: string;
public
property DummyTwo: string read FDummyTwo write FDummyTwo;
end;
[Entity, Automapping]
TChild = class
private
FId: Integer;
public
property Id: Integer read FId write FId;
end;
This is my callstack leading to this error:
Aurelius.Mapping.Explorer.TMappingExplorer.EntityTypeFromClass(TAbstractEntity)
Aurelius.Mapping.Automapping.TAutomapping.AutoGetColumnsFromManyValuedAssociationMember($7BBB7D0)
Aurelius.Mapping.Automapping.TAutomapping.AutoGetColumnsFromAssociationMember($7BBB7D0)
Aurelius.Mapping.Explorer.TMappingExplorer.DefineMetaProperties.AutoMap$ActRec.$0$Body
Aurelius.Mapping.Explorer.TMappingExplorer.LoadPropColumns($42671E0)
Aurelius.Mapping.Explorer.TMappingExplorer.GetColumnsFromProp($42671E0)
Aurelius.Mapping.Explorer.TMappingExplorer.DefineColumns($4285308,TAbstractEntity)
Aurelius.Mapping.Explorer.TMappingExplorer.LoadMapping$ActRec.$1$Body($4285308)
Aurelius.Mapping.Explorer.TMappingExplorer.LoadDetailedAbstractMapping(TMappingExplorer.LoadMapping$ActRec($428DE6C) as {System.SysUtils}TProc<Aurelius.Mapping.Metadata.TAbstractEntityType>,$4285308,$7BB4970)
Aurelius.Mapping.Explorer.TMappingExplorer.ProcessMappedAbstractEntities(TMappingExplorer.LoadMapping$ActRec($428DE6C) as {System.SysUtils}TProc<Aurelius.Mapping.Metadata.TAbstractEntityType>)
Aurelius.Mapping.Explorer.TMappingExplorer.LoadMapping
Aurelius.Mapping.Explorer.TMappingExplorer.FindAbstractEntityType(TChild)
Aurelius.Mapping.Explorer.TMappingExplorer.FindEntityType(TChild)
Aurelius.Mapping.Explorer.TMappingExplorer.GetInheritanceStrategy(TChild)
Aurelius.Mapping.Explorer.TMappingExplorer.InheritsTable(TChild)
Aurelius.Mapping.Explorer.TMappingExplorer.HasTable(TChild)
Aurelius.Engine.DatabaseManager.TDatabaseManager.BuildDatabaseMetadata($4170E10)
Aurelius.Engine.DatabaseManager.TDatabaseManager.ValidateDatabase
Aurelius.Engine.DatabaseManager.TDatabaseManager.UpdateDatabase
wlandgraf
(Wagner Landgraf)
April 1, 2023, 2:54pm
4
I'm sorry, I stand corrected. Many-valued associations are indeed not supported in abstract entities, simply because they need to have the other-side of the association, which references back to the original abstract entity.
Abstract entities cannot be referenced in associations, thus a many-valued association is not possible.