views:

13

answers:

0

[Edit: forget this post - I'm not sure what NHibernate is doing, but it's not doing what I just said it's doing. Please ignore.]

I have a 'parent' class in the object graph called Case.

Here's a snapshot of Case:

public class Case
{
  public virtual Person Deceased {get;set;}
  public virtual IList Executors { get; set; }

  public Case()
  {
    Executors = new List<Executor>();
  }
}

The Executor class also contains a reference to Person:

public class Executor
{
  public virtual Person Person {get;set;}
}

I have omitted mapping code etc becuase I'm not sure it's relevant. I will post it on request.

The problem that I'm having occurs when I construct a Case within an ISession, adding a Person to the Case (as the Deceased property), adding a (different) Person to an Executor and adding the Executor the Case.

When I call session.SaveOrUpdate(Case), NHibernate treats the second Person (within the Executor) as somehow being the same the first Person (within the Case), and so issues an UPDATE against its ID rather than an INSERT.

Just in general, why would this happen?

Thanks

David