For class A
Code:
<class name="A" table="TABLE1">
<id name="id" type="long" column="ID">
<generator class="increment" />
</id>
<property name="x" type="long" column="UNIT" />
<many-to-one name="b" class="B" cascade="all" outer-join="true">
<column name="BID" not-null="true"/>
</many-to-one>
</class>
For B
Code:
<class name="B" table="TABLE2">
<id name="bid" type="long" column="BID">
<generator class="increment" />
</id>
<property name="s" type="string" column="DENOM" />
<property name="id" type="long" column="VALUE" />
<many-to-one name="x" class="A">
<column name="UNIT" />
</many-to-one>
</class>
Table looks like
TABLE1
ID <- Autogenerated
UNIT <- value to propogate
BID <- Value from table 2
TABLE2
BID <- Autogenerated
UNIT <- value to fetch from table 1
VALUE
DENOM
I am saving object of class A that introduces new row for table 2