Hi, I have encountered a problem with associations.
Let's suppose we have the following classes (simplified):
type
[Entity]
[Table('personal_photo')]
[Sequence('SEQ_personal_photo')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TPersonalPhoto = class
private
[Column('PersonalPhoto_ID', [TColumnProp.Unique, TColumnProp.Required, TColumnProp.NoUpdate])]
FId: Integer;
[Column('PersonalPhotoBIN', [TColumnProp.Lazy])]
FPhotoBIN: TBlob;
public
property Id: integer read FId;
property PhotoBIN: TBlob read FPhotoBIN write FPhotoBIN;
end;
and
type
[Entity]
[Table('personal')]
[Sequence('SEQ_personal')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TPersonal = class
private
[Column('Personal_ID', [TColumnProp.Unique, TColumnProp.Required, TColumnProp.NoUpdate])]
FId: Integer;
FLastName: string;
FFirstName: string;
[Association([TAssociationProp.Lazy], CascadeTypeAll)]
[JoinColumn('PersonalPhotoID', [TColumnProp.Unique])]
FPhoto: Proxy<TPersonalPhoto>;
public
[Column('PersonalLastName', [TColumnProp.Required], 100)]
property LastName: string read FLastName write FLastName;
[Column('PersonalFirstName', [TColumnProp.Required], 100)]
property FirstName: string read FFirstName write FFirstName;
property Photo: TPersonalPhoto read GetPhoto write SetPhoto;
end;
In application I create object of TPersonal and I create its Photo property too.
In this case everything is successfully saved. Both objects are created in the tables.
Now I created and saved object of TPersonal and didn't fill TPhoto property.
I load it later and I try to update its TPhoto property.
And when I call FManager.SaveOrUpdate(), I receive an SQLite error 'constraint failed'.
What is wrong in these two classes? Thanks