-->
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: One-to-one:property-ref to a part of composite-key
PostPosted: Fri Jul 03, 2009 10:10 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
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.

My database is legacy and i cannot change it.
I get the one-to-one relationship by applying the condition as:
PRODUCT.PRODUCTID=PRODUCTBASIC.PRODUCTID and USECODE='008' and STARTTIME < CURRENTIME < ENDTIME..
My database values are such that if i apply this condition i will only get once record..

In Product.hbm.xml:

<class name="Product" table="PRODUCT"
<id name="pid" type="string" column="PRODUCTID" length="10">
<generator class="assigned"></generator>
</id>

<one-to-one name="productBasic" class="ProductBasic" constrained="true" outer-join="false" cascade="save-update" property-ref="activeProductBasic" >
<formula>PRODUCTID</formula>
</one-to-one>
</class>


In ProductBasic.hbm.xml

<class name="ProductBasic" table="PRODUCTBASIC">
<composite-id name="compProductBasic" class="CompProductRelatedAssociations">
<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" type="timestamp"/>
</composite-id>

<properties name="activeProductBasic">
<property name="compProductBasic.productId" column="PRODUCTID" type="string" length="10" insert="false" update="false"/>
</properties>
</class>

but this compProductBasic.productId is giving me error...


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.