Vinu,
I'm not that familiar with the annotations approach, as I use configuration files instead, but I've managed to join collections of entities with composite primary key by creating a component in the "one" side of the association with all the columns required for the match. Then use this component in <key> element through the property-ref attribute.
See below the example for a Map (a Set should be the very similar):
Code:
<component name="foreignKey" class="BId" access="field">
<property name="type" column="TYPE" insert="false" update="false" />
<property name="code" column="CODE" insert="false" update="false" />
</component>
<map name="descriptions">
<key property-ref="foreignKey">
<column name="TYPE" />
<column name="CODE" />
</key>
<map-key formula="LANG" type="string" />
<one-to-many class="B" />
</map>
where the primary key for class B is defined as:
Code:
<composite-id name="id" class="BId">
<key-property name="language" column="LANG"/>
<key-property name="type" column="TYPE"/>
<key-property name="code" column="CODE" />
</composite-id></class>
If your composite ID has only 2 fields, then you can create a property instead of a component, as you will only want to match one column (otherwise you will have a one-to-one).
For more details you can check my original post (even though it was about a different problem) at:
http://forum.hibernate.org/viewtopic.php?t=995290
Hope this helps,
Juan