]
Sandeep Vaid commented on HHH-4014:
-----------------------------------
Ans B) The problem is of constrained="true" condition. It should be on proper
one-to-one relationship.
For more details see Java Persistence With Hibernate book, section 7.1.1 The
foreign identifier generator.
Now this issue if resolved. Please close this issue..
One-to-one: property-ref: foreign key: composite-id
---------------------------------------------------
Key: HHH-4014
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4014
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.4.sp1, 3.2.5, 3.2.6, 3.2.7,
3.3.0.CR1, 3.3.0.CR2, 3.3.0.GA, 3.3.0.SP1, 3.3.1, 3.3.2
Environment: Hibernate Version 3.2.6, Database Db2
Reporter: Sandeep Vaid
Priority: Blocker
Presently there is no way in hibernate using which we can specify one-to-one relationship
with property-ref to part of composite-id
of another entity. The following scenario will clarify the above statement.
There is a one-to-one relationship between Product and ProductBasic.
Product -----> productId (PK)
ProductBasic ----> pId, useCode, StartTime (as composite key) and pId is also foreign
key referencing Product.
This is a legacy database. We get one-to-one relationship by using the condition:
Product.productId=ProductBasic.pId and useCode='008' and
startTime<currentTime<endTime.
In Product.hbm.xml:
<one-to-one name="productBasic" cascade="save-update"
property-ref="activeProduct" constrained="true">
<formula>PRODUCTID</formula>
</one-to-one>
In ProductBasic.hbm.xml
<composite-id name="compProductBasic">
<key-property name="pId" column="PID"
></key-property>
<key-property name="useCode" column="USECODE"
"></key-property>
<key-property name="startTime" column="STARTTIME"
></key-property>
</composite-id>
<properties name="activeProduct">
<property name="compProductBasic.pId" class="Product"
insert="false" update="false" lazy="proxy" />
</properties>
If my relationship is Product.productId = ProductBasic.pId, there is no way in hibernate
to specify this relationship.
Moreover we cannot remap(refer to) the property of composite-id (compProductBasic.pId in
current example)..
Hence i request for enhancement in hibernate to incorporate this.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: