AureliusDataset and Nested datasets

HI Wagner,


I'm having some trouble getting a nested dataset to work.  I have a TShip class that should have two TLists of Tests and Hatches.  The hatches work fine but I can't get an AureliusDataset to recognise the tests even though I have done everything the same.  I am using a package to create the field definitions but they are just not there for the tests no matter what I do.  And if I create a TDataSetField manually that doesn't help either.  Do you have any ides?  below is an excerpt of the how the entities are created.

  TShip = class(TPersistent)
  private
  
  ....
    [ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAllRemoveOrphan , 'FShip')]
    FHatches: Proxy<TList<THatch>>;
  ....

    [ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAllRemoveOrphan , 'FShip')]
    FQualities: Proxy<TList<TQuality>>;

    function GetHatches: TList<THatch>;
    function GetQualities: TList<TQuality>;

public
    property Hatches            : TList<THatch>       read GetHatches ;
    property Tests              : TList<TQuality>     read GetQualities ;
end;



  THatch = class(TLocation)
  private
    ...
    [Association([TAssociationProp.Lazy], [])]
    [ForeignKey('FK_LOCATIONS_3')]
    [JoinColumn('SHIP_ID', [])]
    FShip: Proxy<TShip>;
    ...
    function GetShip: TShip;
    procedure SetShip(const Value: TShip);
  public
    property Ship          : TShip             read GetShip      write SetShip;
  end;

  TQuality = class(TPersistent)
  private
    ...
    [Association([TAssociationProp.Lazy], [])]
    [ForeignKey('FK_QUALITY_1')]
    [JoinColumn('SHIP_ID', [])]
    FShip: Proxy<TShip>;
    ...
    function GetShip: TShip;
    procedure SetShip(const Value: TShip);
  public
    property Ship          : TShip               read GetShip        write SetShip;
  end;

implementation


function TShip.GetHatches: TList<THatch>;
begin
  Result := FHatches.Value;
end;

function TShip.GetQualities: TList<TQuality>;
begin
  Result := FQualities.Value;
end;

constructor TShip.Create;
begin
  FHatches.SetInitialValue(TList<THatch>.Create);
  FQualities.SetInitialValue(TList<TQuality>.Create);
end;

destructor TShip.Destroy;
begin
  FHatches  .DestroyValue;
  FQualities.DestroyValue;
  inherited;
end;

function THatch.GetShip: TShip;
begin
  Result := FShip.Value;
end;

procedure THatch.SetShip(const Value: TShip);
begin
  FShip.Value := Value;
end;

function TQuality.GetShip: TShip;
begin
  result := FShip.Value;
end;

procedure TQuality.SetShip(const Value: TShip);
begin
  FShip.Value := Value;
end;

Hi Steve,


there is something strange with your mapping (although it doesn't affect the behavior you're seeing) which is your foreign key name from hatch to ship is named "FK_LOCATIONS_3"? Maybe just an overlook?

Anyway, it doesn't seem to be anything wrong with it. The only difference is that you THatch inherits from TLocation, not TPersistent, and I'm not sure how are the other attributes (Entity, Automapping?) Do you have any inheritance attribute being applied there?

Also, when you say "if I create a TDataSetField manually that doesn't help either", what does exactly happen? What are you doing in this case (source code) and what error message/behavior do you get?

The foreign key name is correct as a hatch is a location on a ship and descends from TLocation so the locations table's foreign key is named this way in the database.


I must of missed something when hooking up the grid to the TDataSetField as I've just manually re-created it again and it's working now but it still won't appear in the list of field definitions provided by the package.  So it is no longer a problem for me as I can work around it but there does appear to be an issue with TAureliusDataset Field Loader.  Anyway thanks once again for your speedy assistance.

Regards

Steve 

Thanks for the feedback. Keep in mind that rebuilding the package is not enough for new classes and properties to appear in TAureliusDataset. You must explicitly open the "Load Field Definitions" popup menu option to reload the field definitions so the field defs are stored in the database. Just using "Add fields..." popup menu option won't bring the new properties automatically.

Maybe that's what's hapenning?