title: Nhibernate , collections and compositeid
body: <p>I have the tables below: </p>
  
  <pre><code>Bucket(
   bucketId smallint (PK)
   name varchar(50)
  )
  
  BucketUser(
   UserId varchar(10) (PK) 
   bucketId smallint (PK)
  )
  </code></pre>
  
  <p>The composite key is not the problem thats ok I know how to get around this but I want my bucket class to contanin a IList of BucketUser. I read the online reference and thought that I had cracked it but havent. The two mappings are below</p>
  
  <p>-- bucket  --</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;class name="Bucket,Impact.Dice.Core" table="Bucket"&gt;
    &lt;id name="BucketId" column="BucketId" type="Int16" unsaved-value="0"&gt;
      &lt;generator class="native"/&gt;
    &lt;/id&gt;
  
    &lt;property column="BucketName" type="String" name="BucketName"/&gt;
  
    &lt;bag name="Users" table="BucketUser" inverse="true" generic="true" lazy="true"&gt;
      &lt;key&gt;
        &lt;column name="BucketId" sql-type="smallint"/&gt;
        &lt;column name="UserId" sql-type="varchar"/&gt;
      &lt;/key&gt;
      &lt;one-to-many class="Bucket,Impact.Dice.Core" not-found="ignore"/&gt;
    &lt;/bag&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>-- bucketUser  --</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;class name="BucketUser,Impact.Dice.Core" table="BucketUser"&gt;
    &lt;composite-id&gt;
      &lt;key-many-to-one name="BucketUser" class="Bucket,Impact.Dice.Core" column="BucketId"/&gt;
      &lt;key-property name="UserId" column="UserId" type="string"&gt;&lt;/key-property&gt;
    &lt;/composite-id&gt;
  &lt;/class&gt;
  </code></pre>