-->
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.  [ 4 posts ] 
Author Message
 Post subject: failed if foreign key is composite-id in many-to-one
PostPosted: Thu Jul 14, 2005 5:59 pm 
Beginner
Beginner

Joined: Tue May 17, 2005 9:10 am
Posts: 29
Hibernate version: hibernate2.0 http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd

Here is what i've tried:
a) <composite-id
name="id"
class="edu.mnscu.housing.vo.RCCampusPK"
>

<key-many-to-one
name="campus"
class="edu.mnscu.housing.vo.Campus"
column="tech_id"
/>
<key-many-to-one
name="campus"
class="edu.mnscu.housing.vo.Campus"
column="rc_id"
/>

...
</composite-id>

I'm getting "Configuration problem: Foreign key (admin_rc_campus [tech_id])) must have same number of columns as the referenced primary key (cr_reporting [tech_id,rc_id])" . It seems to me the second id (ie. "rc_id") is not recognized.


b) if put two ids in one <key-many-to-one>,

<key-many-to-one
name="campus"
class="edu.mnscu.housing.vo.Campus"
column="tech_id,rc_id"
/>

I'm still seeing the disbelievable errors:
"Configuration problem: Foreign key (admin_rc_campus [tech_id,rc_id])) must have same number of columns as the referenced primary key (cr_reporting [tech_id,rc_id])" .

Is this a known issue or what should i do to get around this ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 6:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
<composite-id name="id"
      class="edu.mnscu.housing.vo.RCCampusPK">
   <key-many-to-one name="campus"
          class="edu.mnscu.housing.vo.Campus"
       <column name="tech_id"/>
       <column name="rc_id"/>
   </key-many-to-one>
   ...
</composite-id>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 9:40 am 
Beginner
Beginner

Joined: Tue May 17, 2005 9:10 am
Posts: 29
gavin wrote:
Code:
<composite-id name="id"
      class="edu.mnscu.housing.vo.RCCampusPK">
   <key-many-to-one name="campus"
          class="edu.mnscu.housing.vo.Campus"
       <column name="tech_id"/>
       <column name="rc_id"/>
   </key-many-to-one>
   ...
</composite-id>


well, I'm getting the same result as case a). - the second 'rc_id' is ignored.

"Foreign key (admin_rc_campus [tech_id])) must have same number of columns as the referenced primary key (cr_reporting [tech_id,rc_id])"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 12:39 pm 
Beginner
Beginner

Joined: Tue May 17, 2005 9:10 am
Posts: 29
I just realized that the change doesn't take effect if i manually change the .hbn.xml in war file under *.ear file in jboss /deploy. So actually xdoclet can't generate two <key-many-to-one> in <composite-id> , and can't recognize the non-attribute 'column' .

Here is what i've tried:

1. The goal is to generate :
----
<composite-id
name="id"
class="edu.mnscu.housing.vo.RCCampusPK"
>

<key-many-to-one
name="campus"
class="edu.mnscu.housing.vo.Campus"
column="tech_id"
/>
<key-many-to-one
name="campus"
class="edu.mnscu.housing.vo.Campus"
column="rc_id"
/>
....
</composite-id>

------
//xdoclet
/**
*@hibernate.many-to-one class="edu.mnscu.housing.vo.Campus" column="tech_id" not-null="true"
*@hibernate.many-to-one class="edu.mnscu.housing.vo.Campus" column="rc_id" not-null="true"
*/
//file .hbn.xml generated --- missing another <key-many-to-one> for 'rc_id'.
<composite-id
name="id"
class="edu.mnscu.housing.vo.RCCampusPK"
>

<key-many-to-one
name="campus"
class="edu.mnscu.housing.vo.Campus"
column="tech_id"
/>

...
</composite-id>
2. The goal is to generate the following mapping:
---
<composite-id name="id"
class="edu.mnscu.housing.vo.RCCampusPK">
<key-many-to-one name="campus"
class="edu.mnscu.housing.vo.Campus"
<column name="tech_id"/>
<column name="rc_id"/>
</key-many-to-one>
...
</composite-id>
---
//xdoclet
/**
*@hibernate.many-to-one class="edu.mnscu.housing.vo.Campus"
*@hibernate.column="tech_id" not-null="true"
*@hibernate.column="rc_id" not-null="true"
*/
//file generated -- didn't recognize the 'column' , set the default name 'campus' to column.
<composite-id
name="id"
class="edu.mnscu.housing.vo.RCCampusPK"
>

<key-many-to-one
name="campus"
class="edu.mnscu.housing.vo.Campus"
column="campus"
/>
...
</composite-id>

It works for me if just one column in <composite-id> .<many-to-one>. not the case if a nested composite-id (ie. more than one columns ) in <composite-id>.<many-to-one>. Am i missing something?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.