Exception: TFDPhysPreprocessor is not a valid ...

Hi forum,

I switched my application now to the FireDAC db access.

Now I get some time, not stable reproduceable the following error when I want to remove an object from database by a TNavigatior bound to a TAureliusDataSet. This calls:

  Manager.Remove(Person); // seems to work well
  Manager.Flush;  // But here the exception happens

"Class TFDPhysPreprocessor is not a valid Entity. [Entity] attribute missing."

in Aurelius.Commands.CommandPerformerFactory.pas line 77:

function TCommandPerformerFactory.GetCommand<T>(Clazz: TClass): T;

...
    Result.SetClass(Clazz);
...

Any ideas why?

Thanks
Florian

Hi Florian,

When exactly this code is called? Are there lists (ManyValuedAssociation) in other classes where this Person is present? If yes, you must be sure to remove that reference from those lists otherwise it will reference an invalid object (since Remove) destroys the object.

Hi Wagner,


this happens in:

procedure TDatabaseRepository.DeletePerson(Person: TPerson);
begin
  Manager.Remove(Person);
  Manager.Flush; // << Here
end;

Triggered by the Dataset event OnObjectRemove:

procedure TfrmKunde.adsPersonObjectRemove(Dataset: TDataSet; AObject: TObject);
var uid_Person : TGuid;
  Person : TPerson;
begin

  uid_Person := TPerson(AObject).uid;
  Person := FRepository.GetPerson(uid_Person);

  if Person<>nil then
    FRepository.DeletePerson(Person); // << Here

  UpdateKundeLists;

end;

There is only relations defined pointing to the Person object.
The Person object contains two objects bound with foreign keys and 'no action' properties, but this should be no problem, right?


>> There is only relations defined pointing to the Person object.

If they are lists you should remove Person from those lists. If they are not lists, have you changed the value of those properties since Manager was last flushed/created?