title: NHibernate: mapping user type object to a separate table
body: <p>Let's start with this mapping:</p>
  
  <pre><code>&lt;component name="Location"&gt;
    ...
    &lt;property name="Settings" type="JsonUserType,..."&gt;
      &lt;column name="LocationSettingsType" /&gt;
      &lt;column name="LocationSettingsData" /&gt;
    &lt;/property&gt;
  &lt;/component&gt;
  </code></pre>
  
  <p>This maps to</p>
  
  <pre><code>TABLE Primary (
      ...
      LocationSettingsType,
      LocationSettingsData
      ...
  )
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class Location {
      ...
      object Settings { get; set; }
  }
  </code></pre>
  
  <p>Now, I want to extract settings into a separate table (because they are seldom here).<br>
  So I get</p>
  
  <pre><code>TABLE Primary (
      ...
      LocationSettingsId,
      ...
  )
  
  TABLE Settings (
      Id,
      Type,
      Data
  )
  </code></pre>
  
  <p><strong>Can I keep my C# classes the same?</strong></p>
  
  <p><strong>Update:</strong> This is not a many-to-one relationship. As before, each location has zero or one settings, and each settings belong to at most one location.</p>