NHibernate. Initiate save collection at saving parent

Posted by Andrew Kalashnikov on Stack Overflow See other posts from Stack Overflow or by Andrew Kalashnikov
Published on 2010-03-19T06:52:54Z Indexed on 2010/03/19 7:11 UTC
Read the original article Hit count: 226

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.

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about collections