-->
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 association with composite-id as reference
PostPosted: Tue Mar 29, 2011 5:00 am 
Newbie

Joined: Sat Aug 05, 2006 10:16 pm
Posts: 3
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) ?


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.