Update Cascade On Associations

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.

Many thanks

You didn't define any cascade for UserGrpId, so when saving UserX, the reference in UserGrpId is not persistent. You can't save/update objects which references transient objects.

The only workaround is to retrieve manually the original UserGrpId object, and discard the one that is in TUserX:

UserX.UserGrpId := Manager.Find<TUserGrp>(UserX.UserGrpId.Id);

this will reload the original usergrpid, thus you can save UserX.

Wagner, good trick. I sugest TMS aurelius team considere
I hope that the team consider making this short term. Because in the case of master-detail relationship cascade update makes all sense, in this case does not seems right, at least

should be optional.
Many thanks