I have ran into quite an interesting mapping scenario. I have two entities (Task and ProjectEmployeeFile) that has two identical foreign keys (ProjectId and EmployeeId).
I am trying to find an elegant way to map a Tasks property to the ProjectEmployeeFile entity.
I think that the solution for one foreign key relationship would be by using a ternary association but I have no idea how to project this into multiple foreign keys.
I am using fluent nhibernate but if solving this issue with classic hbm files is the way to go I have no problem with mapping those classes manually.
Any help would be greatly appreciated.
I have drawn a basic diagram to try to illustrate the scenario:

I have mixed property names with database column names freely here but I think the general idea is clear.
update
In order to clarify the domain model, here is the current entities and mappings, stripped to the minimum:
public class Task
{
public virtual int Id { get; private set; }
public virtual Project Project { get; set; }
public virtual Employee Employee { get; set; }
}
public class ProjectEmployeeFile
{
public virtual int Id { get; private set; }
public virtual Project Project { get; set; }
public virtual Employee Employee { get; set; }
}
public class Project
{
public virtual int Id { get; private set; }
public virtual IList<Task> Tasks { get; set; }
}
public class Employee
{
public virtual int Id { get; private set; }
public virtual IList<Task> Tasks { get; set; }
}
public class TaskMap : ClassMap<Task>
{
public TaskMap()
{
Table("Tasks");
Id(x => x.Id);
References(x => x.Project).Column("ProjectId");
References(x => x.Employee).Column("EmployeeId");
}
}
public class ProjectEmployeeFileMap : ClassMap<ProjectEmployeeFile>
{
public ProjectEmployeeFileMap()
{
Table("ProjectEmployeeFiles");
Id(x => x.Id);
References(x => x.Project).Column("ProjectId");
References(x => x.Employee).Column("EmployeeId");
}
}
This mapping might work (I haven’t tested it):
I don’t know if it’s possible to do it with fluent, but you can mix them anyway.