Can't get Concurrency Control to work with XData

My entity:



  [Entity]
  [Table('USUARIOS')]
  [Sequence('SQ_USUARIOS')]
  [Id('FID', TIdGenerator.IdentityOrSequence)]
  TUsuario = class
  private

    [Column('ID', [TColumnProp.Required])]
    FID: Integer;
    [Column('CONTA', [TColumnProp.Required], 255)]
    FConta: string;
    [Column('EMAIL', [TColumnProp.Required], 255)]
    FEmail: string;
    [Column('NOME', [TColumnProp.Required], 65)]
    FNome: string;
    [Column('AVATAR', [TColumnProp.Lazy], 80, 0)]
    FAvatar: TBlob;
    [Version]
    [Column('VERSAO', [])]
    FVersao: Integer;
  public
    property ID: Integer read FID write FID;
    property Conta: string read FConta write FConta;
    property Email: string read FEmail write FEmail;
    property Nome: string read FNome write FNome;
    property Avatar: TBlob read FAvatar write FAvatar;
  end;


This works fine:

GET /tms/xdata/Usuario(1)

This works fine:

PATCH /tms/xdata/Usuario(1)

This DO NOT work:

PUT /tms/xdata/Usuario(1)

I get the folowing error:

{
"error": {
"code": "VersionedConcurrencyControl",
"message": "Could not perform database operation due to optimistic concurrency control. Entity class: "TUsuario", Id: "1", Version: 0"
}
}

It seems It aways read 'Version' as "0" on building the update statement. Any hints?

Ok, I get it. 


I was not including the object 'Version' on the JSON data

Regards,

What is the JSON payload of the request? In PUT requests you have to include all properties of the object. If Version property is missing, it will assume default value (0) and thus will fail. Based on the error message you are getting, it looks like that's what is happening.

Yes Wagner . Sorry and thanks for the fast response.


Regards