#1 2014-06-06 10:10:08

jrvoorhorst
Member
Registered: 2014-06-06
Posts: 14

Retrieve / Update instable (chaching?)

Hello,

I am using Mormot for some weeks now and I am running into problems with my data.

I have some services added to rest server. Within a service I add a new record to database:

ServiceContext.Factory.RestServer.Add(rec);

where rec is my TSQLRecord based data record.

This will always save the info to database as expected.

After that I do a retrieve (in other service call):

ServiceContext.Factory.RestServer.Retrieve(rec_id, rec);

Here it goes wrong. Some fields (not all) are empty, where my database manager tells me the record contains data!

After changing some properties I update the database record with:

ServiceContext.Factory.RestServer.Update(rec_id, rec);

At this point the empty fields will be written to database and overwrite the existing data.


I am using MS SQL Server 2008 Express.

At Global level I defined:

function TdtmlConfig.GetDBConnection: TOleDBMSSQL2008ConnectionProperties;
begin
  if not Assigned(FDBConfig) then
    FDBConfig := TOleDBMSSQL2008ConnectionProperties.Create(FDatabaseServer,FDatabaseName, FDatabaseUser, FDatabasePassword);
  Result := FDBConfig;
end;

When creating the model:

 FModel := TSQLModel.Create([TSQLUploads, TSQLDocuments, TSQLDocumentPages, TSQLAssets, TSQLJoinTest, TSQLTimeline],ROOT_NAME);
  VirtualTableExternalRegisterAll(FModel, dtmlConfig.GetDBConnection, True);

When I get data from database with the same GetDBConnection.Execute, it gives all fields with values. So the dataconnection seems good. It must have to be something in the restserver retrieve function.



Could it be some caching problems?

Thanks for help!

Offline

#2 2014-06-06 11:35:31

jrvoorhorst
Member
Registered: 2014-06-06
Posts: 14

Re: Retrieve / Update instable (chaching?)

I think I got a solution: When I do a ServiceContext.Factory.RestServer.Cache.Flush; the data seems to be correct.

But it keeps strange, because I do not UPDATE this table via direct SQL functions.

So any extra input to understand the mechanism is welcome!

Offline

#3 2014-06-06 11:53:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Retrieve / Update instable (chaching?)

How is your TSQLRecord defined?

Are you using the latest 1.18 nightly zip?

Offline

#4 2014-06-06 12:04:37

jrvoorhorst
Member
Registered: 2014-06-06
Posts: 14

Re: Retrieve / Update instable (chaching?)

I use the 1.18 from 3 weeks ago.

TSQLUploads = class(TSQLRecord)
  private
    FUploadsID: Integer;
    FOrderlineID: RawUTF8;
    FLongID: RawUTF8;
    FOrderXML: RawUTF8;
    FQuantity: Integer;
    FAssigned: Integer;
    FCreated: TCreateTime;
    FUpdated: TModTime;
    FUpdateCount: Integer;
    FJoinList: TSQLJoinTest;
    FUploadsPath: String;
    FChiliWorkspaceID: String;
    FChiliViewPreferencesID: String;
    FChiliConstraintsID: String;
    FChiliFoldingSettingsID: String;
    FUIUploadAllowed: Integer;
    FUIShow3D: Integer;
    FChiliClipartFolderName: String;
    FUIShowPositionList: Integer;
    FUIShowRotation: Integer;
    FUIShowMirroring: Integer;
    FUIAllowPositionNetto: Integer;
    FUIAllowPositionBruto: Integer;
    FUIAllowPositionImageSize: Integer;
    FUIAllowPositionOneCmWhite: Integer;
    FChiliIsGeneralTemplate: Integer;
    function AS_UNIQUE(const Index: Integer): Boolean;
  published
    property OrderlineID: RawUTF8 read FOrderlineID write FOrderlineID;
    property Quantity: Integer read FQuantity write FQuantity;
    property LongID: RawUTF8 index 50 read FLongID write FLongID stored AS_UNIQUE;
    property OrderXML: RawUTF8 read FOrderXML write FOrderXML;
    property Assigned: Integer read FAssigned write FAssigned;
    property Created: TCreateTime read FCreated;
    property Updated: TModTime read FUpdated;
    property UpdateCount: Integer read FUpdateCount write FUpdateCount;
    property JoinList: TSQLJoinTest read FJoinList;
    property UploadsPath: String read FUploadsPath;
    property ChiliIsGeneralTemplate: Integer read FChiliIsGeneralTemplate write FChiliIsGeneralTemplate;
    property ChiliWorkspaceID: String read FChiliWorkspaceID write FChiliWorkspaceID;
    property ChiliViewPreferencesID: String read FChiliViewPreferencesID write FChiliViewPreferencesID;
    property ChiliConstraintsID: String read FChiliConstraintsID write FChiliConstraintsID;
    property ChiliFoldingSettingsID: String read FChiliFoldingSettingsID write FChiliFoldingSettingsID;
    property ChiliClipartFolderName: String read FChiliClipartFolderName write FChiliClipartFolderName;
    property UIUploadAllowed: Integer read FUIUploadAllowed write FUIUploadAllowed;
    property UIShow3D: Integer read FUIShow3D write FUIShow3D;
    property UIShowPositionList: Integer read FUIShowPositionList write FUIShowPositionList;
    property UIShowMirroring: Integer read FUIShowMirroring write FUIShowMirroring;
    property UIShowRotation: Integer read FUIShowRotation write FUIShowRotation;
    property UIAllowPositionImageSize: Integer read FUIAllowPositionImageSize write FUIAllowPositionImageSize;
    property UIAllowPositionBruto: Integer read FUIAllowPositionBruto write FUIAllowPositionBruto;
    property UIAllowPositionNetto: Integer read FUIAllowPositionNetto write FUIAllowPositionNetto;
    property UIAllowPositionOneCmWhite: Integer read FUIAllowPositionOneCmWhite write FUIAllowPositionOneCmWhite;
  end;

Last edited by jrvoorhorst (2014-06-12 08:04:01)

Offline

#5 2014-06-06 13:03:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Retrieve / Update instable (chaching?)

Could you look at the json content stored in the cache?

Offline

#6 2014-06-06 14:03:03

jrvoorhorst
Member
Registered: 2014-06-06
Posts: 14

Re: Retrieve / Update instable (chaching?)

Sorry, how do I get that?

ServiceContext.Factory.RestServer.Cache.?

Thanks!

Offline

#7 2014-06-06 14:56:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Retrieve / Update instable (chaching?)

Use the step by step debugger when retrieving the record.

Then check the local variables content.

Offline

#8 2014-06-12 08:03:36

jrvoorhorst
Member
Registered: 2014-06-06
Posts: 14

Re: Retrieve / Update instable (chaching?)

When I inspect the retrieved TSQL... record without flushing cache before, some properties are empty (although there is data in database for that record), other are filled with correct values.

Offline

#9 2014-06-12 08:42:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Retrieve / Update instable (chaching?)

Is the data stored in the cache correct?
Why are they missing fields?

Offline

Board footer

Powered by FluxBB