Hi,
I've declared these two classes (via Data Modeller):
------------------
[Entity]
[Table('UserTS')]
[Id('FUserTSID', TIdGenerator.IdentityOrSequence)]
TUserTS = class
private
[Column('UserTSID', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FUserTSID: integer;
[Column('CreateUser', [])]
FCreateUser: Nullable<integer>;
[Column('CreateTS', [], 65536)]
FCreateTS: Nullable<string>;
[Column('ModifyUser', [])]
FModifyUser: Nullable<integer>;
[Column('ModifyTS', [], 65536)]
FModifyTS: Nullable<string>;
[Column('Comments', [], 65536)]
FComments: Nullable<string>;
public
property UserTSID: integer read FUserTSID write FUserTSID;
property CreateUser: Nullable<integer> read FCreateUser write FCreateUser;
property CreateTS: Nullable<string> read FCreateTS write FCreateTS;
property ModifyUser: Nullable<integer> read FModifyUser write FModifyUser;
property ModifyTS: Nullable<string> read FModifyTS write FModifyTS;
property Comments: Nullable<string> read FComments write FComments;
end;
[Entity]
[Table('SysPreferences')]
[Id('FSysPrefsID', TIdGenerator.IdentityOrSequence)]
TSysPreferences = class
private
[Column('SysPrefsID', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FSysPrefsID: integer;
[Column('LastUser', [])]
FLastUser: Nullable<integer>;
[Column('MultiUser', [])]
FMultiUser: Nullable<integer>;
[Association([TAssociationProp.Lazy], [])]
[JoinColumn('UserTSID', [], 'UserTSID')]
FUserTSID: Proxy<TUserTS>;
function GetUserTSID: TUserTS;
procedure SetUserTSID(const Value: TUserTS);
public
property SysPrefsID: integer read FSysPrefsID write FSysPrefsID;
property LastUser: Nullable<integer> read FLastUser write FLastUser;
property MultiUser: Nullable<integer> read FMultiUser write FMultiUser;
property UserTSID: TUserTS read GetUserTSID write SetUserTSID;
end;
-----------
Then, in code I try to create a record like this:
tmpTS:=TUserTS.Create;
tmpSys:=TSysPreferences.Create;
tmpSys.LastUser:=1;
tmpTS.CreateUser:=1;
tmpTS.ModifyUser:=1;
tmpSys.UserTSID:=tmpTS;
AppDatabases.GetObjectManager.Save(tmpSys); //This returns a reference to ObjectManager
and compiler (Delphi XE7) complains that "Association references a transient object"
I've checked the manual and know the difference between transient/persistent objects. When I check the class declarations I think both TUserTS and TSysPreferences are persistent.
So, what am I doing wrong here?
Thanks
John