-->
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.  [ 2 posts ] 
Author Message
 Post subject: Primary key generation based on mapping.
PostPosted: Tue Feb 20, 2007 1:51 pm 
Newbie

Joined: Mon Feb 19, 2007 2:53 pm
Posts: 4
Hi,

Pardon me for reposting this question. I was not really clear in my first post.

Following is my Transaction.hbn.xml:
Code:
<hibernate-mapping auto-import="true" default-lazy="true">
<class
    name="TransactionVO"
    table="cdhc.TRANSACTION"
>   
    <id
        name="transaction_id"
        type="java.lang.String"
        column="transaction_id"
    >
     <generator class="sequence">
      <param name="sequence">CDHC.TRANSACTION_ID_SEQ</param>
     </generator>
    </id>
   
   <property
        name="vendor_id"
        type="java.lang.String"
        column="vendor_id"
        not-null="true"
        length="50"
    />

    <one-to-one
       name="mq_transaction"
       class="MQ_TransactionVO"
       cascade="save-update"
     />
</class>
</hibernate-mapping>


Following is my MQ_Transaction.hbn.xml:
Code:
<hibernate-mapping auto-import="true" default-lazy="false">
<class
    name="MQ_TransactionVO"
    table="cdhc.MQ_TRANSACTION"
>
     <id
        name="mq_transaction_id"
        type="java.lang.String"
        column="transaction_id"
    >
    </id>
   
    <property
        name="vendor_id"
        type="java.lang.String"
        column="vendor_id"
        not-null="false"
        length="24"
    />
   
     <one-to-one
         name="transaction"
         class="TransactionVO"
    /> 
</class>
</hibernate-mapping> 


What I want is for the MQ_Transaction table to have the same PK that the Transaction table has, without explicitly setting it. The Transaction table has a Primary Key generated because I am using a sequence generator. But what about MQ_Transaction? What property should I use for the MQ_Transaction table, so that it can have the same Primary Key that the Transaction table had?

Thanks for your help.
-MP


Top
 Profile  
 
 Post subject: you can.
PostPosted: Wed Feb 21, 2007 7:53 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
read this link,

http://saloon.javaranch.com/cgi-bin/ubb ... 8&t=001798.

_________________
Please vote if my Postings helps. :-)


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

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.