-->
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.  [ 2 posts ] 
Author Message
 Post subject: How do i map it in one-to-many relation?
PostPosted: Sat Sep 02, 2006 5:29 pm 
Newbie

Joined: Fri Jul 28, 2006 9:52 am
Posts: 12
I have two tables which has one to many relationship. My problem in mapping these two table is the relationship between these two table is not based on the primary key column.

For eg:
Table1: TABLE-A
Table2: TABLE-B

TABLE-A contains two columns say ACOLUMN1 ACOLUMN2 which combines to form unique in this table.

TABLE-B has the same reference of ACOLUMN1,ACOLUMN2 as AC1,AC2 which is not uinique so as to form the one-to-many relationship. how should i map in hbm.

I tried like the following

TABLE-A
----------
Code:
<properties name="comp_id">
    <property name="aCol1" column="ACOLUMN1" />
    <property name="aCol2" column="ACOLUMN2" />
</properties>

<set>
        <key property-ref="comp_id">
             <column name="AC1" />
             <column name="AC2" />
        </key>
</set>


TABLE-B
----------
Code:
<property name="ac1" column="AC1">
<property name="ac2" column="AC2">


but this throws the following error
Code:
org.hibernate.MappingException: collection foreign key mapping has wrong number of columns: com.mypackage.myclass type: component[aCol1,aCol2]


is something wrong in this???


Top
 Profile  
 
 Post subject: Its working...:))
PostPosted: Mon Sep 04, 2006 12:07 pm 
Newbie

Joined: Fri Jul 28, 2006 9:52 am
Posts: 12
My problem is solveed.

Sorry its my fault.. i typed the wrong column name in the set of one-many relationship.

so it works in the above specified. nothing wrong it the above implementation.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.