-->
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: Foreign key mapping to non-id field possible?
PostPosted: Sat Mar 04, 2006 3:12 am 
Newbie

Joined: Sat Mar 04, 2006 2:50 am
Posts: 3
I want to create a set collection relationship between two classes Foo containing many Bar objects. However, due to data constraints I need to have the foreign key for the collection be the "customKey" property rather than the "id" property which usually serves as foreign key. I've experimented with a few configurations but no matter what config I try I cannot create the relationship that uses that "customKey/CUSTOM_KEY" as the foreign key.

Is there a way to create the relationship I desire.

The fragments below demonstrate what I would like to do.

Code:
     <class name="Foo">
        <id name="id" column="ORDER_ID">
            <generator class="increment"/>
        </id>
        <!-- I wan't to use customKey as the foreign key rather
               than id above assume that customKey is unique -->
        <property name="customKey" column="CUSTOM_KEY"/>
       
        <set name="bars" cascade="all">
            <key>
               <column name="CUSTOM_KEY" sql-type="VARCHAR(36)"/>
            </key>
            <one-to-many class="org.awp.Bar"/>
        </set>
    </class>


    <class name="Bar">
        <id name="id" column="BAR_ID">
            <generator class="increment"/>
        </id>
    </class>


Thanks in adavance for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 04, 2006 3:17 am 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
you can make use of the "property-ref" attribute .

_________________
sHeRiN
thanks for your ratings ...... :)


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.