title: Fluent NHibernate Composite ID table problem
body: <p>I'm kinda new to nhibernate and i ran into a problem.
  I have the following tables:</p>
  
  <p><em><strong>Table 1:</em></strong> 
  <strong>Table Name:</strong> Users, 
  <strong>Column 1:</strong> ID,
  <strong>Column 2:</strong> Name</p>
  
  <p><em><strong>Table 2:</em></strong> 
  <strong>Table Name:</strong> Missions,
  <strong>Column 1:</strong> ID,
  <strong>Column 2:</strong> Description</p>
  
  <p><em><strong>Table 3:</em></strong> 
  <strong>Table Name:</strong> UserToDoMissions,
  <strong>Column 1:</strong> UserID,
  <strong>Column 2:</strong> MissionID,
  <strong>Column 3:</strong> Rank</p>
  
  <p>Here is the code:
  MissionMap:</p>
  
  <pre><code>public class MissionMap : ClassMap&lt;Mission&gt;
  {
      public const string TableName = "tblMissions";
      public const string c_id = "achID";
      public const string c_name = "achName";
  
      public MissionMap()
      {
          Table(TableName);
          Id(x =&gt; x.ID).Column(c_id).Not.Nullable();
          Map(x =&gt; x.Name).Column(c_name).Not.Nullable();
  
          HasMany(x =&gt; x.UserToDoList).Cascade.All().Inverse().KeyColumn(UserToDoMap.c_missionID);
      }
  }
  </code></pre>
  
  <p>User Map:</p>
  
  <pre><code>public class UserMap : ClassMap&lt;User&gt;
  {
      public const string TableName = "tblUsers";
      public const string c_id = "usrID";
      public const string c_userName = "usrUserName";
  
      public UserMap()
      {
          Table(TableName);
          Id(x =&gt; x.ID).Column(c_id).Not.Nullable();
          Map(x =&gt; x.UserName).Column(c_userName).UniqueKey(DBConsts.UniqueKeys.User_UserName).Not.Nullable();
  
          HasMany(x =&gt; x.UserToDoList).Cascade.All().Inverse().KeyColumn(UserToDoMap.c_userID);
      }
  }
  </code></pre>
  
  <p>UserToDo Map:</p>
  
  <pre><code>public class UserToDoMap : ClassMap&lt;UserToDo&gt;
  {
      public const string TableName = "tblToDoList";
      public const string c_userID = "tdlUserID";
      public const string c_missionID = "tdlMissionID";
      public const string c_rank = "tdlRank";
  
      public UserToDoMap()
      {
          Table(TableName);
          CompositeId().KeyReference(x =&gt; x.User, c_userID).KeyReference(x =&gt; x.Achievment, c_missionID);
          References(x =&gt; x.User).Column(c_userID).Cascade.All().UniqueKey(DBConsts.UniqueKeys.ToDoList_UserRanks).Not.Nullable();
          References(x =&gt; x.Mission).Column(c_missionID).Cascade.All().Not.Nullable();
          Map(x =&gt; x.Rank).Column(c_rank).UniqueKey(DBConsts.UniqueKeys.ToDoList_UserRanks).Not.Nullable();
      }
  }
  </code></pre>
  
  <p>My problem is that i can;t save a new line. I can select and get all of the things but can't save.
  Any ideas?</p>
  
  <p>Thanks.</p>
  
  <p>Edit:
  I'm not getting anything. No exception is thrown but the row isn't added to the DB.
  BTW, I'm using the save method on UserToDo object.</p>
  
  <p>Edit 2:
   After docmanhattan answer here is the code:</p>
  
  <p>UserToDoMap:</p>
  
  <pre><code>public class UserToDoMap : ClassMap&lt;UserToDo&gt;
  {
      public const string TableName = "tblToDoList";
      public const string c_userID = "tdlUserID";
      public const string c_missionID = "tdlMissionID";
      public const string c_rank = "tdlRank";
  
      public UserToDoMap()
      {
          Table(TableName);
          CompositeId&lt;UserToDoId&gt;(x =&gt; x.ID)
              .KeyReference(x =&gt; x.UserIdPart, c_userID)
              .KeyReference(x =&gt; x.MissionIdPart, c_missionID);
          References(x =&gt; x.ID.UserIdPart).Column(c_userID).Cascade.All().UniqueKey(DBConsts.UniqueKeys.ToDoList_UserRanks).Not.Nullable();
          References(x =&gt; x.ID.MissionIdPart).Column(c_missionID).Cascade.All().Not.Nullable();
          Map(x =&gt; x.Rank).Column(c_rank).UniqueKey(DBConsts.UniqueKeys.ToDoList_UserRanks).Not.Nullable();
      }
  }
  </code></pre>
  
  <p>UserToDoId entity:</p>
  
  <pre><code>public class UserToDoId
  {
      public virtual User UserIdPart { get; set; }
      public virtual Mission MissionIdPart { get; set; }
  
      public override bool Equals(object obj)
      {
          UserToDoId recievedObject = (UserToDoId)obj;
  
          if ((UserIdPart.ID == recievedObject.UserIdPart.ID) &amp;&amp;
              (MissionIdPart.ID == recievedObject.MissionIdPart.ID))
          {
              return (true);
          }
  
          return (false);
      }
  
      public override int GetHashCode()
      {
          return base.GetHashCode();
      }
  }
  </code></pre>
  
  <p>UserToDo entity:</p>
  
  <pre><code>public class UserToDo
  {
      public virtual UserToDoId ID { get; set; }
  
      public virtual int Rank { get; set; }
  
      public UserToDo()
      {
  
      }
  
      public override bool Equals(object obj)
      {
          UserToDo recievedObject = (UserToDo)obj;
  
          if ((ID.UserIdPart.ID == recievedObject.ID.UserIdPart.ID) &amp;&amp;
              (ID.MissionIdPart.ID == recievedObject.ID.MissionIdPart.ID) &amp;&amp;
              (Rank == recievedObject.Rank))
          {
              return (true);
          }
  
          return (false);
      }
  
      public override int GetHashCode()
      {
          return base.GetHashCode();
      }
  }
  </code></pre>
  
  <p>I'm getting the exception when i'm trying to create the session factory: </p>
  
  <blockquote>
    <p>{"Could not find a getter for property 'UserIdPart' in class 'DatabaseEntities.UserToDo'"}</p>
  </blockquote>