Composite ID insert bug


I believe that there is a bug in TObjectMap.HasIdValue when composite Ids are used. Consider the following definition:

  [Id('FId', TIdGenerator.Guid)]
  TOrmProject = class(TOrmBase)
    [Column('idproject', [TColumnProp.Required], 32)]
    FId: string;
    [Column('author', [], 255)]
    FAuthor: Nullable<string>;
    [Column('lockedby', [], 32)]
    FLockedBy: Nullable<string>;
    [ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAllRemoveOrphan, 'FProject')]
    FMeta: Proxy<TList<TOrmProjectmeta>>;
  private  // -- Methods
    function GetMeta: TList<TOrmProjectmeta>;
  public   // -- Constructor and Destructor
    constructor Create;
    destructor Destroy; override;
    property Id: string read FId write FId;
    property Author: Nullable<string> read FAuthor write FAuthor;
    property LockedBy: Nullable<string> read FLockedBy write FLockedBy;
    // Other tables
    property Meta: TList<TOrmProjectmeta> read GetMeta;

  [Id('FKey', TIdGenerator.None)]
  [Id('FProject', TIdGenerator.None)]
  TOrmProjectmeta = class(TOrmBase)
    [Column('key', [TColumnProp.Required], 255)]
    FKey: string;
    [Column('value', [TColumnProp.Lazy])]
    FValue: Nullable<string>;
    [Column('lockedby', [], 32)]
    FLockedBy: Nullable<string>;
    [Association([TAssociationProp.Lazy], [])]
    [JoinColumn('idproject', [TColumnProp.NoUpdate], 'idproject')]
    FProject: Proxy<TOrmProject>;
    property Key: string read FKey write FKey;
    property Value: Nullable<string> read FValue write FValue;
    property LockedBy: Nullable<string> read FLockedBy write FLockedBy;
    property Project: Proxy<TOrmProject> read FProject write FProject;

The following code will try to Update ProjectsMeta instead of Insert, because it thinks that the ID field "Key" has been defined. But the Id field is a composite ID between "Key" and "Project":

  // Create a new project
  aProject := TOrmProject.Create();
  aProject.Author := 'Sample Author';
  // Create a new meta
  aProjectMeta := TOrmProjectMeta.Create();
  aProjectMeta.Key := 'aMetaKey';
  aProjectMeta.Value := 'aMetaValue';
  // Save everything

What would be the work-around here ?
Node: This is a legacy DB so I can't add an ID to the ProjectsMeta table.


This is not related to HasIdValue, but the fact that entities with user-assigned id's cannot be used in a SaveOrUpdate call - and thus cannot be cascaded.

There is no way for Aurelius to tell if the id is supposed to be updated or inserted. For entities with manually-assigned id, the only safe way to work with them is not using cascade and save ProjectsMeta manually, and then save Project.