title: Nhibernate Best way to mapping Parent > Child
body: <p>I'm new in NHibernate and I have some doubts. I'll put my code bellow and then I'll explain.</p>
  
  <p>My tables:
  <img src="https://i.stack.imgur.com/0NiNJ.png" alt="https://dl.dropbox.com/u/423844/map%20db.png"></p>
  
  <p>My classes: </p>
  
  <pre><code>public class IntegratorModel : PGIBaseModel&lt;int&gt;, IIntegratorModel
  {
      public virtual string Identifier { get; set; }
  
      public virtual string Name { get; set; }
  
      public virtual string Description { get; set; }
  }
  
  public class ClientModel : PGIBaseModel&lt;int&gt;, IClientModel
  {
      public virtual string Name { get; set; }
  
      public virtual string TokenPGI { get; set; }
  
      public virtual IIntegratorModel Integrator { get; set; }
  }
  </code></pre>
  
  <p>My mappings using Fluent:</p>
  
  <pre><code>public class IntegratorMappingOverride : IAutoMappingOverride&lt;IntegratorModel&gt;
  {
      public virtual void Override(AutoMapping&lt;IntegratorModel&gt; mapping)
      {
          mapping.Map(model =&gt; model.Identifier).Column("Identifier").Length(4);
          mapping.Map(model =&gt; model.Name).Column("Name").Length(200);
          mapping.Map(model =&gt; model.Description).Column("Description").Length(2000);
      }
  }
  
      public class ClientMappingOverride : IAutoMappingOverride&lt;ClientModel&gt;
  {
      public virtual void Override(AutoMapping&lt;ClientModel&gt; mapping)
      {
          mapping.Map(model =&gt; model.Name).Column("Name").Length(200);
          mapping.Map(model =&gt; model.TokenPGI).Column("TokenPGI").Length(50);
  
          mapping.References&lt;IntegratorModel&gt;(model =&gt; model.Integrator);
      }
  }
  </code></pre>
  
  <p>I'm saving IntegratorModel previously in another moment, so when I'm inserting a new ClientModel I already have the IntegratorID, so it's ok. </p>
  
  <p>My question is when I'm updating ClientModel and I want to change IntegratorID in the database, I'm doing something like this: </p>
  
  <pre><code>    IClientModel model = this.GetModelFromPost();
      model.Integrator = integratorBLL.LoadByID(context.Request.Form["IntegratorID"]));
      clientBLL.Save(model);
  </code></pre>
  
  <p>integratorBLL.LoadByID just will call ISession.Load from NHibernate. Maybe I'm wrong, but Load doesn't hit the database in this moment. </p>
  
  <p>My question is if what I'm doing is correct. 
  In this case, won't be easier if I had some property IntegratorID directly in ClientModel e just updated it? </p>
  
  <p>Cause, in my architeture, I have to call my BLL of Integrator, call Load and then set the return in ClientModel property. </p>
  
  <p>This code works, but cause I'm new at Nhibernate, I think that probably there's another way to do it better. </p>