Ok, this is what I ended up with and it works fine.
This is real entity that represents B
Code:
<hibernate-mapping default-lazy="false">
<class name="CifsShare" table="CifsShare">
<composite-id name="key" class="CifsSharePk">
<key-property name="dataStoreId" />
<key-property name="primaryIpAddr"/>
<key-property name="shareName"/>
</composite-id>
<property name="fileSystem"/>
<property name="relativePath"/>
<property name="description"/>
<properties name="joinRefCifsServer">
<property name="shareName" insert="false" update="false"/>
</properties>
</class>
</hibernate-mapping>
This is real entity that represents A
Code:
<hibernate-mapping default-lazy="false" >
<class name="CifsFileServer" table="CifsFileServer">
<composite-id name="key" class="CifsFileServerPk">
<key-property name="dataStoreId" />
<key-property name="primaryIpAddr"/>
<key-property name="cifsIpAddr"/>
</composite-id>
<property name="adJoinDomain"/>
<property name="adNetbiosName"/>
<property name="netbiosName"/>
<set name="cifsShares" table="CifsServerShares" cascade="save-update">
<key>
<column name="dataStoreId"/>
<column name="primaryIpAddr"/>
<column name="cifsIpAddr"/>
</key>
<many-to-many class="CifsShare" property-ref="joinRefCifsServer"/>
</set>
</class>
</hibernate-mapping>
Thanks for your help!