Hi,
I've got thsi class:
[Entity]
[Table('AssessmentTypes')]
[Id('FAssessmentTypeID', TIdGenerator.IdentityOrSequence)]
TAssessmentTypes = class
private
[Column('AssessmentTypeID', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FAssessmentTypeID: integer;
[Column('Active', [])]
FActive: Nullable<integer>;
[Column('Description', [TColumnProp.Required], 65356)]
FDescription: string;
[Column('Short', [], 65536)]
FShort: Nullable<string>;
[Column('CreateUSer', [])]
FCreateUSer: Nullable<integer>;
[Column('ModifyUser', [])]
FModifyUser: Nullable<integer>;
[Column('CreateTS', [], 65536)]
FCreateTS: Nullable<string>;
[Column('ModifyTS', [], 65536)]
FModifyTS: Nullable<string>;
[Column('Comments', [], 65536)]
FComments: Nullable<string>;
public
property AssessmentTypeID: integer read FAssessmentTypeID write FAssessmentTypeID;
property Active: Nullable<integer> read FActive write FActive;
property Description: string read FDescription write FDescription;
property Short: Nullable<string> read FShort write FShort;
property CreateUSer: Nullable<integer> read FCreateUSer write FCreateUSer;
property ModifyUser: Nullable<integer> read FModifyUser write FModifyUser;
property CreateTS: Nullable<string> read FCreateTS write FCreateTS;
property ModifyTS: Nullable<string> read FModifyTS write FModifyTS;
property Comments: Nullable<string> read FComments write FComments;
end;
and when I do this:
....ObjectManager1.Find<TAssessmentTypes>(5); //id:5 exists in the DB
I get the correct record.
Then, I have this class:
[Entity]
[Table('EdRoleSets')]
[Id('FEdRoleSetID', TIdGenerator.IdentityOrSequence)]
TEdRoleSets = class
private
[Column('EdRoleSetID', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FEdRoleSetID: integer;
[Column('Active', [])]
FActive: Nullable<integer>;
[Column('Description', [TColumnProp.Required], 65536)]
FDescription: string;
[Column('Short', [], 65536)]
FShort: Nullable<string>;
[Column('CreateUser', [])]
FCreateUser: Nullable<integer>;
[Column('ModifyUser', [])]
FModifyUser: Nullable<integer>;
[Column('CreateTS', [], 65536)]
FCreateTS: Nullable<string>;
[Column('ModifyTS', [], 65536)]
FModifyTS: Nullable<string>;
[Column('Comments', [], 65536)]
FComments: Nullable<string>;
public
property EdRoleSetID: integer read FEdRoleSetID write FEdRoleSetID;
property Active: Nullable<integer> read FActive write FActive;
property Description: string read FDescription write FDescription;
property Short: Nullable<string> read FShort write FShort;
property CreateUser: Nullable<integer> read FCreateUser write FCreateUser;
property ModifyUser: Nullable<integer> read FModifyUser write FModifyUser;
property CreateTS: Nullable<string> read FCreateTS write FCreateTS;
property ModifyTS: Nullable<string> read FModifyTS write FModifyTS;
property Comments: Nullable<string> read FComments write FComments;
end;
and when I do this:
...ObjectManager1.Find<TEdRoleSets>(5)΄//5 exists
I get rubbish....
Is it because there is another class that defines the following field?
[Association([TAssociationProp.Lazy, TAssociationProp.Required], CascadeTypeAll)]
[JoinColumn('EdRoleSetID', [TColumnProp.Required], 'EdRoleSetID')]
FEdRoleSetID: Proxy<TEdRoleSets>;
function GetEdRoleSetID: TEdRoleSets;
procedure SetEdRoleSetID(const Value: TEdRoleSets);
What am I missing here?
Thanks
What do you mean by rubbish, exactly? I can't see anything wrong in your mapping at first sight.
I mean I get neither the record from the database nor NIL. The return is a huge ID number and unrecognisable characters in the strings...like a memory dump
Are you sure the object was not destroyed after you retrieved it and before you read the properties?
Which object do you mean? The object manager?
I get the result like this:
var
tmp:TEdRoleSets;
tmp:=...ObjectManager1.Find<>(5);
Wagner,
another question but relevant to the code above.
The last snippet is from a class which linkes to the second class I show above.
If I delete a record of that class, should the linked class (with the snippet) be AUTOMATICALLy deleted since it has the CascadeAll property? or I have to do something else?
Yes, it will be deleted. And the associated object will be destroyed. That's what I mean, are you sure the object was not destroyed?
Not sure what was wrong. I deleted the code and rewrote it and now it seems to work correctly.
Thanks again