Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="learn.hibernate">
<class name="ClassA" table="A">
<id name="aId" type="long" column="a_id" />
<property name="aProperty" column="a_prop" />
<set name="bSet"
lazy="true"
inverse="true"
cascade="all-delete-orphan">
<key>
<column name="a_id" />
</key>
<one-to-many class="learn.hibernate.ClassB"/>
</set>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="learn.hibernate">
<class name="ClassB" table="B">
<composite-id>
<key-property name="bIdOne" column="b_id" />
<key-property name="bIdTwo" column="a_id" />
</composite-id>
<property name="bProperty" column="b_prop" />
<many-to-one name="aObject"
class="learn.hibernate.ClassA"
column="a_id"
insert="false" update="false"/>
</class>
</hibernate-mapping>