I have my objects defined
[Entity]
[Automapping]
[Sequence('SYS_GEN')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TToken = class
private
FId: Integer;
FTokenValue: string;
FCreated: TDateTime
public
property Id: Integer read FId write FId;
property TokenValue: String read FTokenValue write FTokenValue;
property Created: TDateTime read FCreated write FCreated;
end;
[Entity]
[Automapping]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TProfile = class
private
FId: Integer;
FName: String;
[ManyValuedAssociation([TAssociationProp.Required], CascadeTypeAllRemoveOrphan)]
[ForeignJoinColumn('PROFILE_ID', [TColumnProp.Required])]
FTokens: TList<TToken>;
public
property Id: Integer read FId write FId;
property Name: String read FName write FName;
property Tokens: TList<TToken> read FTokens write FToken;
end;
This seems to create the correct database structure with the filed 'PROFILE_ID' in the TOKEN table and a foreign key as expected.
CONSTRAINT FK_AUTH_TOKEN_PROFILE_PROFILE_ FOREIGN KEY (PROFILE_ID) REFERENCES PROFILE (ID)
In my application I have 2 Aureulius datasets dsProfile and dsToken. I have loaded the fields from a package built with the entities and I set the dsToken.DatasetField to the appropriate field from dsProfile.
However when I append a record to dsToken and post the changes I get
exception class ESQLiteException with message 'NOT NULL constraint failed: TOKEN.PROFILE_ID'
From the documents it's not clear what else I need to do, unless I need to add an Association to TToken, but the documents seem to say you only need to do that if you want a two way relationship, which isn't necessary in this case.
Thanks