njel_valdez wrote:
hi,
i'm looking for sample application that shows how to map multiple primary key.i am mapping a table that has two primary key these are the following fields :
computer_id, user_id
thanks in advance.
i was reading the nhibernate reference material and i found the solution to my problem.here is the sample hbm.xml file. i use the <composite-id> to tag multiple primary keys.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="WindowsApplication1.User, WindowsApplication1" table="users">
<composite-id>
<key-property name="Id" column="Computer_id" type="String" length="20"/>
<key-property name="UserID" column="user_id" type="String" length="40"/>
</composite-id>
<property name="Password" type="String" length="20"/>
<property name="EmailAddress" type="String" length="40"/>
<property name="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>