Hi All,
I want to make use of join query for many to one relationship.
I have two problem -
1. using hbm2ddl.auto the join table is not getting created. (others are getting created)
Then manually I created the table and started using it. I inserted 1 row in each of joined tables(without any relation b/w them). Later I load both the rows frm tables, put the relation b/w thm and try to update the object.
2. When I set the relation b/w those two, in the join table one entry row should get inserted which will contain IDs from both the table(for joining). But whats happening is instead of insert command, hibernate is running update command -
update midwayhas.APP_BP_DI_MAP set BID=? where DID=?
Can any one tell me why above mentioned 2 issues are there.
Here goes my mapping for two classes -
<class name="com.emc.hpr.databaseapi.threshold.DeviceInstance" table="dwd_instance">
<id name="did" type="integer">
<column name="instancekey" />
<generator class="assigned" />
</id>
<join table="APP_BP_DI_MAP">
<key column="DID" unique="true"/>
<many-to-one name="bPolicy" column="BID" not-null="true" cascade="save-update"/>
</join>
</class>
and
<class name="com.emc.hpr.databaseapi.threshold.BaselinePolicy" table="APP_BASELINE_POLICY">
<id name="bid" type="integer">
<column name="BID" />
<generator class="native" />
</id>
</class>
|