Hello!
I have a problem when applying updates in a dataset. This method worked until few months ago, but after opening a project, recompiling it and running it it fails when i do an ApplyUpdates. The error is in the XData server after calling ApplyChanges in the WebCore app.
Project Orders.Server.VCL.exe raised exception class EAssociationReferencesTransientObject with message 'Association references a transient object.
Parent: Entities.TOdvoz(12), Transient: Entities.TVehicle(5), Association: FVehicle'.
The code below is simplified, to be shorter I removed all the other properties that are not related.
First I save the vehicle object in a TWebDataModule property
..
TmodMain = class(TWebDataModule)
private
...
public
...
Vozilo: TObject;
...
end;
When the user logs in the WebCore application, I save the vehicle object for later usage:
procedure TmodMain.wdsVehicleAfterOpen(DataSet: TDataSet);
begin
Vehicle := TObject(TXDataWebDataSet(DataSet).CurrentData);
end;
Then (in another form of the WebCore application) I use the object after opening a dataset.
procedure TfrmOdvoz.wdsOdvozAfterOpen(DataSet: TDataSet);
var cas: TTime;
begin
wdsOdvoz.Append;
wdsOdvoz.FieldByName('Id').AsInteger := 0; // New record, without this I get an error on Posting.
wdsOdvoz.FieldByName('Vehicle').Value := modMain.Vehicle;
// Tried also this, but same result.
// wdsOdvoz.FieldByName('Vozilo').Value := modMain.wdsVozila.CurrentData;
wdsOdvoz.Post;
end;
When i click the save button, this code is executed
.. editing of the wdsOdvoz fields, not related to field "Vehicle"
wdsOdvoz.ApplyUpdates;
The error is raised on the REST server (XData). It all worked without problems a few months before.
Please, help!
Kind regards
m@rko