title: Nhibernate mapping value object with references as properties
body: <p>I have following entities
  <code>Country</code>, <code>State</code>, <code>City</code></p>
  
  <p>I have also <code>User</code> entity.</p>
  
  <p><code>Country</code>, <code>State</code> and the <code>City</code> does not have relationship with user entity. 
  <code>User</code> does not have direct relationship with <code>Country</code>, <code>State</code> or <code>City</code>.</p>
  
  <p>I want to be able to update user address details in a way that
  user will select country, state and city and save this values. 
  I'm thinking to introduce <code>Address</code> value object which will store this user address information.</p>
  
  <p>Is this good idea? How would you handle this scenario?</p>
  
  <p>I'm using nhibernate orm and mapping using Conformist (mapping by code approach)
  So I was thinking to map Address as value object</p>
  
  <pre><code>Component(c =&gt; c.Address, AddressMap.Mapping());
  
  public class AddressMap
      {
          public static Action&lt;IComponentMapper&lt;Address&gt;&gt; Mapping()
          {
              return c =&gt;
              {
                  c.Property(p =&gt; p.Country);
                  c.Property(p =&gt; p.State);                    
                  c.Property(p =&gt; p.City);
              };
          }
      }
  </code></pre>
  
  <p>having this in <code>UserMap</code></p>
  
  <pre><code>Component(c =&gt; c.Address, AddressMap.Mapping());
  </code></pre>
  
  <p>I'm getting following error</p>
  
  <blockquote>
    <p>The type initializer for 'NHibernate.SessionProvider' threw an
    exception. {"Could not determine type for: Model.Country, ..., for
    columns: NHibernate.Mapping.Column(Country)"}</p>
  </blockquote>
  
  <p>Without this line <code>Component(c =&gt; c.Address, AddressMap.Mapping());</code> in <code>UserMap</code> I do not have any error (also I do not have Address value object mapped :).</p>