Cascade Update should be optional, on a "Association/LookupField" relationship.
Hi,
I have the classes above:
[Entity]
[Table('UserX')]
[Sequence('Id_UserX')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TUserX = class
private
[Column('Id', [TColumnProp.Required])]
FId: Int64;
[Column('UserName', [TColumnProp.Required], 20)]
FUserName: string;
[Association([TAssociationProp.Required], [])]
[JoinColumn('UserGrpId', [TColumnProp.Required], 'Id')]
FUserGrpId: TUserGrp;
public
property Id: Int64 read FId write FId;
property UserName: string read FUserName write FUserName;
property UserGrpId: TUserGrp read FUserGrpId write FUserGrpId;
end;
[Entity]
[Table('UserGrp')]
[Sequence('Id_UserGrp')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TUserGrp = class
private
[Column('Id', [TColumnProp.Required])]
FId: Int64;
[Column('Description', [TColumnProp.Required], 20)]
FDescription: string;
public
property Id: Int64 read FId write FId;
property Description: string read FDescription write FDescription;
end;
I need to Save or Update the UserX object in the Database,
UPDate: ERRO: "Association references a transient Object."
Manager.Merge(UserX)
Manager.Flush;
SAVE: ERRO: "Association references a transient Object."
Manager.Save(NewDBObject);
Manager.Flush;
if i change the Association Cascade to "All but remove"
[Association([TAssociationProp.Required], CascadeTypeAll - [TCascadeType.Remove])]
User Object is saved, but also save the UserGrp and i don't want update UserGrp Object.
How to do that?
This is the typical example where the user have rights to save/update
the User information, but don't have rights to save/update UserGrp, just read.