hi,
i know i'm missing something blindingly obvious, but i'm struggling to get the list mapping to work. say i have:
Code:
   public class ClassA
   {
      public ClassA()
      {
         TheBs = new List<ClassB>();
      }
      public virtual int Id { get; set; }
      public virtual string Prop1 { get; set; }
      public virtual IList<ClassB> TheBs { get; protected set; }
   }
   public class ClassB
   {
      public virtual int Id { get; set; }
      public virtual string Prop2 { get; set; }
   }
and i map it with:
Code:
   <class name="ClassA">
      <id name="Id">
         <generator class="native" />
      </id>
      <property name="Prop1"/>
      <list name="TheBs" cascade="all-delete-orphan" inverse="false" >
         <key column="AID"/>
         <index column="BIDX"/>
         <one-to-many class="ClassB"/>         
      </list>
   </class>
   <class name="ClassB">
      <id name="Id">
         <generator class="native" />
      </id>
      <property name="Prop2"/>
   </class>
if i run the following unit test:
Code:
      [Test]
      public void Should_return_a_with_one_b_child()
      {
         ClassA a = new ClassA { Prop1 = "prop1" };
         a.TheBs.Add(new ClassB {  Prop2 = "prop2" });
         session.Save(a);
         int id = a.Id;
         session.Evict(a);
         a = session.Get<ClassA>(id);
         Assert.That(a, Has.Property("Prop1").EqualTo("prop1"));
         Assert.That(a.TheBs, Has.Count.EqualTo(1));
      }
i get:
Code:
NHibernate: INSERT INTO applicant.ClassA (Prop1) VALUES (@p0); select SCOPE_IDENTITY(); @p0 = 'prop1'
NHibernate: INSERT INTO applicant.ClassB (Prop2) VALUES (@p0); select SCOPE_IDENTITY(); @p0 = 'prop2'
NHibernate: SELECT classa0_.Id as Id6_0_, classa0_.Prop1 as Prop2_6_0_ FROM applicant.ClassA classa0_ WHERE classa0_.Id=@p0; @p0 = '2'
NHibernate: SELECT thebs0_.AID as AID__1_, thebs0_.Id as Id1_, thebs0_.BIDX as BIDX__1_, thebs0_.Id as Id7_0_, thebs0_.Prop2 as Prop2_7_0_ FROM applicant.ClassB thebs0_ WHERE thebs0_.AID=@p0; @p0 = '2'
how do i get class b's to cascade correctly. what's wrong with my mapping? i've googled this as much as possible, but all the examples use bags. maybe there's a reason for this...
ps. i'm on version 1.2.