Hi,
I have problems adding one-to-one association to existing table. How am I suppose to associate these tables given this condition on tables structure:
This is table PRSN_INFO:
Code:
<hibernate-mapping auto-import="true" default-lazy="false">
<class name="PrsnInfo" table="PRSN_INFO">
<id name="personId" type="string" column="person_id" length="16">
<generator class="assigned"/>
</id>
<property name="position" column="position" type="string" length="10" not-null="false"/>
<property name="district" column="district" type="string" length="4" not-null="false"/>
...
</class>
</hibernate-mapping>
An this is table CLASS_POS:
Code:
<hibernate-mapping auto-import="true" default-lazy="false">
<class name="ClassPos" table="CLASS_POS">
<composite-id name="compId" class="PKOhclassPos">
<key-property name="positionId" column="position_id" type="string" length="10"/>
<key-property name="dstrctCode" column="dstrct_code" type="string" length="4"/>
</composite-id>
</class>
...
</hibernate-mapping>
Where prsnInfo.
position should be refer to classPos.compId.
positionId, and prsnInfo.
district should be refer to classPos.compId.
dstrctCode.
Unfortunately, my current projects is using hibernate for sometimes now and decide not to use the hibernate association, untiil now.
I have tried adding this to PrsnInfo.hbm.xml:
Code:
<one-to-one name="classPos" class="com.mitrais.kms.ohs.config.OhclassPos"/>
but were to no avail and produce this error:
Code:
org.hibernate.MappingException: broken column mapping for: classPos.id of: PrsnInfo
My question so far is: how we tells hibernate that we should referenced a composite-id by two columns (
position and
district) ?