-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: A one-to-one mapping problem
PostPosted: Thu Sep 20, 2007 10:51 am 
Newbie

Joined: Thu Sep 20, 2007 10:34 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.