I need to flatten a relational structure. I am performing a projection based upon joined data. I've not included the projection below because it's not relevant to my question.
Using ICriteria I receive a "NHibernate.QueryException: duplicate association path: Parent.Child" exception with the following query:
Code:
ICriteria q = session.CreateCriteria(typeof(Parent), "p")
.CreateCriteria("p.Child", "c1", JoinType.LeftOuterJoin)
.Add(Expression.Eq("c1.Key", 'VALUE_1'))
.CreateCriteria("p.Child", "c2", JoinType.LeftOuterJoin)
.Add(Expression.Eq("c2.Key", 'VALUE_2');
However the equivalent IQuery is valid:
Code:
select from Parent p
left outer join p.Child c1
left outer join p.Child c2
where c1.Key = 'VALUE_1'
and c2.Key = 'VALUE_2'
Have I missed something? Is this a known problem?