title: nHibernate 2.0 - mapping a composite-id *and* many-to-one relationship causes "invalid index" error
body: <p>I have a problem.  Imagine this data model:</p>
  
  <pre><code>[Person] table has: PersonId, Name1  
  [Tag] table has:  TagId, TagDescription  
  [PersonTag] has: PersonId, TagId, IsActive
  </code></pre>
  
  <p>Since <code>[PersonTag]</code> isn't just a simple many-to-many join table, I have all three entities created in nHibernate (exactly like they are in the data model). <code>PersonTag</code>, therefore, needs a composite-id, which I have mapped to a class like this:</p>
  
  <pre><code>&lt;composite-id name="PersonTagKey" class="PersonTagKey"&gt;
    &lt;key-property name="PersonId"&gt;&lt;/key-property&gt;
    &lt;key-property name="TagId"&gt;&lt;/key-property&gt;
  &lt;/composite-id&gt; 
  </code></pre>
  
  <p>I want to traverse the object graph and be able to look at both the <code>Person</code> and <code>Tag</code> objects from a retrieved <code>PersonTag</code> object.  So, I have properties on the <code>PersonTag</code> object to do that, mapped like this:</p>
  
  <pre><code>&lt;many-to-one name="Person" column="PersonId" lazy="proxy" cascade="none" class="Person"/&gt;
  &lt;many-to-one name="Tag" column="TagId" lazy="proxy" cascade="none" class="Tag"/&gt;
  </code></pre>
  
  <p>When I try to create a <code>PersonTag</code> object and save it, I get an <em>"Invalid index n for this SqlParameterCollection with Count=n"</em> error.  I know this is because I've mapped the <code>PersonId</code> and <code>TagId</code> properties twice, once for the composite-id, and once for the many-to-one relationship. If I don't map the many-to-one objects, then everything works fine.</p>
  
  <p><em>Is there some way for me to be able to have a composite-id AND a many-to-one relationship based on the same column modeled in the same nHibernate entity?</em></p>