Nhibernate , collections and compositeid

Posted by Ciaran on Stack Overflow See other posts from Stack Overflow or by Ciaran
Published on 2009-04-19T20:33:12Z Indexed on 2010/04/29 20:17 UTC
Read the original article Hit count: 435

Filed under:
|
|
|

Hi, banging my head here and thought that some one out there might be able to help. Have Tables below.

Bucket(
 bucketId smallint (PK)
 name varchar(50)
)

BucketUser(
 UserId varchar(10) (PK) 
 bucketId smallint (PK)
)

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

-- bucket --

	<id name="BucketId" column="BucketId" type="Int16" unsaved-value="0">
		<generator class="native"/>
	</id>
	<property column="BucketName" type="String" name="BucketName"/>

<bag name="Users" table="BucketUser" inverse="true" generic="true" lazy="true">
  <key>
    <column name="BucketId" sql-type="smallint"/>
    <column name="UserId" sql-type="varchar"/>
  </key>
  <one-to-many class="Bucket,Impact.Dice.Core" not-found="ignore"/>
</bag>

-- bucketUser --

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about composite