This should be simple problem to solve but I am battling get the
mapping correct. I have a container with two separate collections
containing the same type. Everything works as expected but when
retrieving the object from the DB both collections are populated with
each other's items.
Here are my code and mapping file:
-----------------------------------------------------------------------------------
public class Container
{
public virtual IList<ValueItem> IncomeItems { get; set; }
public virtual IList<ValueItem> ExpenseItems { get; set; }
}
public class ValueItem
{
public virtual double Amount { get; set; }
public virtual string Description { get; set; }
}
<class name="Container">
<id name="Id">
<generator class="hilo" />
</id>
<list name="IncomeItems " cascade="all-delete-orphan">
<key column="ContainerId" />
<index column="ItemIndex" />
<one-to-many class="ValueItem"/>
</list>
<list name="ExpenseItems " cascade="all-delete-orphan">
<key column="ContainerId" />
<index column="ItemIndex" />
<one-to-many class="ValueItem"/>
</list>
</class>
<class name="ValueItem">
<id column="Id" type="int">
<generator class="hilo" />
</id>
<property name="Amount" />
<property name="Description" />
</class>
-----------------------------------------------------------------------------------
The behaviour is understandable because there are no 'type qualifier'
on the VaueItem table that would serve as a filter when retrieving the
data. How they describe this requirement in the mapping file?
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.