Dear All,
I am trying to learn one-to-one mapping in Hibernate. Could anyone please help me out? This was what I had tried:
Transaction.hbm.xml and MqTransaction.hbm.xml:
Code:
<class name="cdhc.dao.valueobjects.TransactionVO" table="CDHC.TRANSACTION">
<id name="txnId" type="java.lang.String" column="TRANSACTION_ID" >
<generator class="sequence">
<param name="sequence">cdhc.transaction_id_seq</param>
</generator>
</id>
...
<one-to-one name="MqTransaction" class="cdhc.dao.valueobjects.MqTransactionVO" />
</class>
----------------------
----------------------
<class name="cdhc.dao.valueobjects.MqTransactionVO" table="MQ_TRANSACTION">
<id name="txnId" column="TRANSACTION_ID" >
<generator class="foreign">
<param name="property">TransactionVO</param>
</generator>
</id>
...
<one-to-one name="Transaction" class="cdhc.dao.valueobjects.TransactionVO" constrained="true"/>
</class>
Then, I set the values (Please note that I do not set the primary key values, because I'm already using the generator classes):
Code:
TransactionVO tVo = new TransactionVO();
tVo.setColumns(...);
MqTransactionVO mqTVo = new MqTransaction();
mqTVo.setColumns(...);
tVo.setMqTransaction(mqTVo);
//Then I saveOrUpdate the session and I'm done.
Now the problem I have is, I only see the Transaction table being inserted, and I am not being able to see any corresponding columns in the MqTransaction.
Can someone please help me?
Thank you,
-VG