Hi
I have a problem when nesting joins in a deep graph, eg like this...
Code:
IList<A> res = Session.CreateCriteria(typeof (A))
.SetFetchMode("BCollection", FetchMode.Join)
.SetFetchMode("BCollection.CCollection", FetchMode.Join)
.SetResultTransformer(CriteriaUtil.DistinctRootEntity)
.List<A>();
...the resulttransformer only "distincting" the root, not the BCollection which will contain multiple duplicates if there are multiple C items. Cannot really find a nice work around either.
The above criteria query using the following mapping...
Code:
<class name="A">
<id name="Id"
type="guid"
unsaved-value="null">
<generator class="guid.comb" />
</id>
<bag name="BCollection"
cascade="all-delete-orphan"
inverse="true">
<key column ="Parent" />
<one-to-many class="B" />
</bag>
</class>
<class name="B">
<id name="Id"
type="guid"
unsaved-value="null">
<generator class="guid.comb" />
</id>
<many-to-one name="Parent"
class="A"
not-null="true"/>
<bag name="CCollection"
cascade="all-delete-orphan"
inverse="true">
<key column ="Parent" />
<one-to-many class="C" />
</bag>
</class>
<class name="C">
<id name="Id"
type="guid"
unsaved-value="null">
<generator class="guid.comb" />
</id>
<many-to-one name="Parent"
class="B"
not-null="true"/>
</class>
Anyone?
/Roger