Hello Wagner how are you?
The behavior of the relationship between tables and foreign keys has been shown to be a
great challenge to adjust this with TMS Aurelius, because every time I have a relationship between 1:1
it creates the foreign key in the master table and not in the detail is it possible to reverse this behavior?
In my database the foreign key is always in detail and never in master.
It would be very important in TMS aurelius some parameter to adjust how this relationship between first and foreign key
must occur, in the "LEFT" table or in the "RIGHT" table
In my example, a foreign key was created in the "LINK" table, but the correct
would be to create a foreign key in the "SCRIPT" table
Thanks for your attention.
unit UnitEntity;
interface
uses
// System
System.Generics.Collections,// TMS
Aurelius.Mapping.Attributes, Aurelius.Types.Nullable, Aurelius.Types.Proxy;type
[Entity]
[Table('SCRIPT')]
[Id('FId', TIdGenerator.SmartGuid)]
TScript = class
private
[Column('ID', [TColumnProp.Required, TColumnProp.NoUpdate])]
FId: TGUID;[Column('SOURCE', [])] FSource: Nullable< string >;
public
property Id: TGUID read FId write FId;
property Source: Nullable< string > read FSource write FSource;
end;[Entity]
[Table('LINK')]
[Id('FId', TIdGenerator.SmartGuid)]
TLink = class
private
[Column('ID', [TColumnProp.Required, TColumnProp.NoUpdate])]
FId: TGUID;[Association([TAssociationProp.Lazy], CascadeTypeAll)] [JoinColumn('ID_SCRIPT', [], 'ID')] FScript: Proxy< TScript >; [Column('URL', [])] FUrl: Nullable< string >;
protected
function GetScript: TScript;
procedure SetScript( const Value: TScript );
public
property Id: TGUID read FId write FId;
property Url: Nullable< string > read FUrl write FUrl;
property Script: TScript read GetScript write SetScript;
end;[Entity]
[Table('PROCESS')]
[Id('FId', TIdGenerator.SmartGuid)]
TProcess = class
private
[Column('ID', [TColumnProp.Required, TColumnProp.NoUpdate])]
FId: TGUID;[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAll)] [ForeignJoinColumn('ID_PROCESS', [], 'ID')] FLink: Proxy< TList< TLink > >; [Column('NAME', [])] FName: Nullable< string >;
protected
function GetLinks: TList< TLink >;
public
constructor Create; virtual;
destructor Destroy; override;property Id: TGUID read FId write FId; property Name: Nullable< string > read FName write FName; property Link: TList< TLink > read GetLinks;
end;
implementation
{ TProcess }
constructor TProcess.Create;
begin
inherited;
FLink.SetInitialValue( TList< TLink >.Create );
end;destructor TProcess.Destroy;
begin
FLink.DestroyValue;
inherited;
end;function TProcess.GetLinks: TList< TLink >;
begin
Result := FLink.Value;
end;{ TLink }
function TLink.GetScript: TScript;
begin
Result := FScript.Value;
end;procedure TLink.SetScript( const Value: TScript );
begin
FScript.Value := Value;
end;initialization
RegisterEntity(TLink);
RegisterEntity(TScript);
RegisterEntity(TProcess);end.