Phillip,
I have a similar mapping to yours, except that I am using bags instead
of lists, I have inverse="true", cascade set to the default, I
explicitly set the table name, I have different column names for each
key, and I have references back to what would be your Container with
unique names for each. Perhaps it's the inverse=true or the different
column names.
Sorry about the hokey class names. I changed them from the real
domain object names on the spot, and I'm not feeling very creative.
Hope this helps,
Don
<class name="Form" >
<many-to-one name="CreatorPerson" class="Person" />
<many-to-one name="ProcessorPerson" class="Person" />
</class>
<class name="Person">
<bag name="FormsCreated" inverse="true">
<key>
<column name="CreatorPersonId" not-null="true" />
</key>
<one-to-many class="Person" />
</bag>
<bag name="FormsToProcess" inverse="true">
<key>
<column name="ProcessorPerson" not-null="true" />
</key>
<one-to-many class="Person" />
</bag>
</class>
On Mar 25, 1:30 pm, Philip Fourie <[email protected]> wrote:
> 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.