Wagner,
I a FiscalYear table which has an ID (Integer) primary key column and a unique key with a composite key (StartDate, EndDate). I also have a related table called FiscalYearClosure which references (StartDate, EndDate). I created the relationship in this manner to enforce that FiscalYearClosure.Date is between FiscalYear.StartDate and FiscalYear.EndDate in the database.
I have not been able correctly set a ManyValueAssociation in the TFiscalYear class. Are ForeignJoin argument required to reference the column(s) of a primary key only or can they reference a unique key also?
Here is how I have coded the relationship
[Entity]
[Table('T_FISCAL_YEAR')]
[ID('ID', TIdGenerator.IdentityOrSequence)]
[UniqueKey('START_DATE, END_DATE')]
[UniqueKey('FIRST_DAY_OF_SCHOOL, LAST_DAY_OF_SCHOOL')]
TFiscalYear = class(TCustomFiscalYear)
private
[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAll - [TCascadeType.Remove])]
[ForeignJoinColumn('FISCAL_YEAR_START_DATE', [TColumnProp.Required], 'START_DATE')]
[ForeignJoinColumn('FISCAL_YEAR_END_DATE', [TColumnProp.Required], 'END_DATE')]
FClosureList: Proxy<TList<TFiscalYearClosure>>;
end;
[Entity]
[Table('T_FISCAL_YEAR_CLOSURE')]
[ID('ID', TIdGenerator.IdentityOrSequence)]
TFiscalYearClosure = class(TCustomSchoolClosure)
private
[Association([TAssociationProp.Lazy], CascadeTypeAll - [TCascadeType.Remove])]
[JoinColumn('FISCAL_YEAR_START_DATE', [TColumnProp.Required], 'START_DATE')]
[JoinColumn('FISCAL_YEAR_END_DATE', [TColumnProp.Required], 'END_DATE')]
FFiscalYear: Proxy<TFiscalYear>;
end;