DZone Forums
Go Back   DZone Forums > Community > Languages & Frameworks > Java
Reload this Page One-to-one:property-ref to a part of composite-key
Notices
Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Mar 2009
Default One-to-one:property-ref to a part of composite-key - 07-03-2009, 10:11 AM

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...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Part of Composite-Id is foreign Key:How specify in Mapping? CatchSandeepVaid Java 0 07-03-2009 07:44 AM
one-to-one with property-ref always non-lazy CatchSandeepVaid Java 1 05-26-2009 08:50 AM
Property View Label Provider herciu.adrian Eclipse 1 05-19-2009 07:24 AM
swing UI & property prefixes xcolwell Java 0 01-02-2009 03:53 PM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com