I have the following example of using composite-id element in mapping file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="com.real.app.ContentKeyword"
table="CONTENT_KEYWORDS"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false">
<composite-id>
<key-many-to-one
name="content"
class="com.real.app.Content"
column="CONTENT_ID">
</key-many-to-one>
<key-many-to-one
name="keyword"
class="com.real.app.Keyword"
column="KEYWORD_ID">
</key-many-to-one>
</composite-id>
<property
name="sortOrder"
column="SORT_ORDER"
not-null="false"/>
</class>
</hibernate-mapping>
Hope this example will help you to start playing with composite-id mapping element in your application