-->
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: Part of Composite-Id is foreign Key:How specify in Mapping?
PostPosted: Fri Jul 03, 2009 7:41 am 
Beginner
Beginner

Joined: Wed Aug 22, 2007 5:53 am
Posts: 38
I have 2 classes viz. Product and ProductBasic having one-to-one relationship

class Product{
String productId;
ProductBasic productBasic;
}

class ProductBasic{
String productId;
String useCode;
TimeStamp startTime;

Product product;
}

Product is mapped to a table PRODUCT which has PRODUCTID as PK.
ProductBasic is mapped to a table PRODUCTBASIC which has PRODUCTID,USECODE and STARTTTIME as composite key.
Also PRODUCTID (of PRODUCTBASIC table) is the foreign key referencing PRODUCT table...

How can i define my one-to-one mapping considering ProductBasic.productId should get its value from Product.productId ?


<composite-id>
<key-property name="productId" column="PRODUCTID" type="string" length="10" />
<key-property name="useCode" column="USECODE" type="string" length="10" />
<key-property name="startTime" column="STARTTIME" />
<composite-id>

In this only productId is the foreign key..

I am aware that i can use a <generator> tag (with class="foreign") inside <composite-id> but i guess it will generate the
value for entire composite-id and not just a field of it.


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.