Hello,
I've got a problem using XData with a class with composite ID: when I call XDataClient.Post method, my object is correctly saved in DB, but when XDataClient tries to set the Id from the response, I get an exception that says:
"Composite Id value must be a variant array
( ..\TMS Aurelius\source\core\Aurelius.Mapping.Explorer.pas, line 2408)"
My class is this:
[Entity]
[Table('MP_PRODUCTLOT')]
[Id('FYEAR',TIdGenerator.None)]
[Id('FNUMBER',TIdGenerator.None)]
TMP_PRODUCTLOT = class
private
[Column('LOT_YEAR',[TColumnProp.Required],4)]
FYEAR: string;
[Column('LOT_NUMBER',[TColumnProp.Required],5)]
FNUMBER: string;
[Column('ARRIVAL_DATE',[TColumnProp.Required])]
FARRIVAL_DATE: TDate;
[Association([],CascadeTypeAllButRemove)]
[JoinColumn('ID_MASTER_PRODUCT',[TColumnProp.Required])]
FMP: TMP_MP;
[Column('PRODUCT_LOT_NUMBER',[TColumnProp.Required],16)]
FPRODUCTOR_LOT_NUM: string;
[Column('QTY',[TColumnProp.Required])]
FQTY: integer;
[Column('EXPIRE_DATE',[])]
FEXPIRE_DATE: TDate;
[Column('AVAILABLE_QTY',[TColumnProp.Required])]
FAVAILABLE_QTY: integer;
[Column('DDT',[TColumnProp.Required],15)]
FDDT: string;
[Column('ID_SUPPLIER',[TColumnProp.Required])]
FSUPPLIER: integer;
public
procedure clear;
property YEAR: string read FYEAR write FYEAR;
property NUMBER: string read FNUMBER write FNUMBER;
property ARRIVAL_DATE: TDate read FARRIVAL_DATE write FARRIVAL_DATE;
property MP: TMP_MP read FMP write FMP;
property PRODUCTOR_LOT_NUM: string read FPRODUCTOR_LOT_NUM write
FPRODUCTOR_LOT_NUM;
property SUPPLIER: integer read FSUPPLIER write FSUPPLIER;
property DDT: string read FDDT write FDDT;
property EXPIRE_DATE: TDate read FEXPIRE_DATE write FEXPIRE_DATE;
property QTY: integer read FQTY write FQTY;
property AVAILABLE_QTY: integer read FAVAILABLE_QTY write FAVAILABLE_QTY;
end;
[Entity]
[Table('MP_MASTER_PRODUCTS')]
[Sequence('SEQ_MASTERPRODUCT_ID')]
[Id('FID_MP',TIdGenerator.IdentityOrSequence)]
TMP_MP = class
private
[Column('ID',[TColumnProp.Unique,TColumnProp.NoUpdate])]
FID_MP: integer;
[Column('START_DATE',[TColumnProp.Required])]
FSTART_DATE: TDate;
[Column('TS',[TColumnProp.Required])]
FTS_MASTER_PRODUCT: TDateTime;
[Column('END_DATE',[TColumnProp.Required])]
FEND_DATE: TDate;
[Association([],CascadeTypeAllButRemove)]
[JoinColumn('ID_PRODUCT_CATEGORY',[TColumnProp.Required])]
FPC: TMP_PC;
protected
public
procedure clear;
procedure init;
property ID_MP: integer read FID_MP write
FID_MP;
property START_DATE: TDate read FSTART_DATE write FSTART_DATE;
property END_DATE: TDate read FEND_DATE write FEND_DATE;
property PC: TMP_PC read FPC
write FPC;
property TS_MP: TDateTime read FTS_MASTER_PRODUCT write
FTS_MASTER_PRODUCT;
end;
If it can help, in debug mode I found that in XData.Aurelius.Model, in function TXDataAureliusModel.KeyPredicateToId, ALiteral argument contains only values of Composite Id and not their names: in fact, at row 572, when it tries to copy the string, there is no name and then the Variant Array cannot be built.