views:

36

answers:

1

Hello, colleagues. I've got a problem at saving my entity. MApping:

 ?xml version="1.0" encoding="utf-8" ?>
 <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
               assembly="Clients.Core"
               namespace="Clients.Core.Domains">
<class name="Sales, Clients.Core" table='sales'>
   <id name="Id" unsaved-value="0">
  <column name="id" not-null="true"/>
  <generator class="native"/>
</id>
<property name="Guid">
  <column name="guid"/>
</property>
<set name="Accounts" table="sales_users" lazy="false">
  <key column="sales_id" />
  <element column="user_id" type="Int32" />
</set>

Domain:

public class Sales : BaseDomain
{
    ICollection<int> accounts = new List<int>();
    public virtual ICollection<int> Accounts
    {
        get { return accounts; }
        set { accounts = value; }
    }
    public Sales() { }           
}

When I save Sales object Account collection don't save at sales_users table. What should I do for saving it? Please don't advice me use classes inside List

Thanks a lot.

+1  A: 

Looks like you're missing the cascade attribute when you map the collection.

R0MANARMY