I have a very simple class containing a component
Code:
public class Party : Entity
{
private Address address;
private string telephone;
private string email;
#region Constructors
public Party() : this(null)
{
}
public Party(string name) : this(name, null)
{
}
public Party(string name, string telephone) : this(name, telephone, null)
{
}
public Party(string name, string telephone, string email) : base(name)
{
address = new Address();
Telephone = telephone;
Email = email;
}
#endregion
/// <summary>
/// Property Address (Address)
/// </summary>
public Address Address
{
get { return address; }
set { address = value; }
}
public string Telephone
{
get { return telephone; }
set { telephone = value; }
}
public string Email
{
get { return email; }
set { email = value; }
}
}
And I've mapped Address as a component
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="Lbth.Sar.Domain" assembly="Lbth.Sar.Domain" default-access="field.camelcase">
<subclass name="Party" extends="Entity" discriminator-value="Party">
<property name="Email" column="Email" type="String" />
<property name="Telephone" column="Telephone" type="String" />
<component name="Address" class="Address">
<property name="Street" column="Street" type="String" />
<property name="City" column="City" type="String" />
<property name="Postcode" column="Postcode" type="String" />
<property name="County" column="County" type="String" />
</component>
</subclass>
</hibernate-mapping>
Problem is, when I load Party that has an empty address, i.e. all the values of the component are null, then the Address reference is null as well.
I know I'm being thick somehow, but I haven't dealt with components for couple of months