Hi, guys....I got into an issue and I'm trying to solve it for a time with no success.....hope you can give me a piece of advice here. I'll explain the situation using a simple test :
Supose we have two classes like this:
Code:
public class Address
{
public string City { get; set; }
public string Street { get; set; }
public int Block { get; set; }
}
and
Code:
public class Person
{
public Guid Id { get; set; }
public string Name { get; set; }
public Address Address{get; set; }
}
and Address property of Person is mapped as component:
Code:
<class name="Person">
<id
name="Id" type="guid">
<generator class="guid" />
</id>
<property name="Name" type="string" />
<component name="Address" class="Address">
<property name="City" type="string" />
<property name="Street" type="string" />
<property name="Block" type="int" />
</component>
</class>
then the following test will fail :
Code:
[Test]
public void Should_Save_Person_Without_Address()
{
var person = new Person { Name = "Bill" };
using (var session = sessionFactory.OpenSession())
using (var transaction = session.BeginTransaction())
{
session.SaveOrUpdateCopy(person);
transaction.Commit();
}
}
I tend to believe this is a bug...as SaveOrUpdate() works....I need to use SaveOrUpdateCopy() to avoid exceptions when using different sessions
I'm using NHibernate 2.0.0.1001