Hi,
A list of objects of type Class1 with a <bag> collection of type Class2 need to be loaded. The mappings are:
Class1:
<bag name="Class2Property"
table="Class2"
cascade="all-delete-orphan"
inverse="false"
lazy="false"
fetch="join">
<key column="Class1Id" />
<one-to-many class="Class2"/>
</bag>
Class2: not important.
Whats the case:
- if fetch="join" is not set (default select) NHibernate generates too many select queries (I think it is so called "N + 1 problem").
- if fetch="join" is set, equal objects of the collection are selected (the same object is included in the collection more than once, because of some outer join).
So, how to tell NHibernate not to include the same object more than once in the collection?
|