-->
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: foreign key problem
PostPosted: Mon Sep 12, 2005 4:42 am 
Newbie

Joined: Mon Sep 12, 2005 4:32 am
Posts: 1
Location: Posen - Poland
Hi all;

I use hibernate 3.1 beta 1 and I am encountering following problem during schema generation:

org.hibernate.MappingException: Foreign key (FK2E507FF63F66BF:bugs [pid])) must have same number of columns as the referenced primary key (projects [nickname,pid])

Here are my mappings:
Code:
<class name="model.Bug" table="bugs">
       
        <id name="id" column="id">
           <generator class="increment"/>
        </id>
       
        <property name="summary"/>
        <property name="description"/>
       
        <many-to-one name="importancy" class="model.BugImportancy" foreign-key="id"/>
       
      <join table="projects" inverse="true" optional="true">
           <key column="id"/>
         <many-to-one name="project" column="pid" not-null="true"/>
      </join>
       
       
        <join table="users" inverse="true" optional="true">
           <key column="id"/>
           <many-to-one name="hunter" column="nickname" not-null="true"/>
        </join>
       
        <join table="users" inverse="true" optional="true">
           <key column="id"/>
           <many-to-one name="mechanic" column="nickname" not-null="true"/>
        </join>
       
   
    </class>

<class name="model.Project" table="projects">
       
        <id name="id" column="pid">
           <generator class="increment"/>
        </id>
       
        <property name="name"/>
        <property name="description"/>
        <property name="technologies"/>
        <property name="website"/>
        <property name="accepted"/>
       
       
       
        <set name="workers" inverse="true">
           <key column="pid"/>
           <many-to-many column="nickname" class="model.User"/>
        </set>
       
        <set name="bugs" table="bugs">
           <key column="pid"/>
           <many-to-many column="id" unique="true" class="model.Bug"/>
        </set>
   
      <join table="users" inverse="true" optional="true">
           <key column="pid"/>
           <many-to-one name="owner" column="nickname" not-null="true" class="model.User"/>
        </join>
       
    </class>

<class name="model.User" table="users">
        <id name="nickname" type="string" column="nickname">
           <generator class="assigned">
           </generator>
        </id>
       
        <property name="email"/>
        <property name="name"/>
        <property name="password"/>
        <property name="phone"/>
        <property name="surname"/>
        <property name="referencesCount"/>
        <property name="referencesMean"/>
        <property name="accepted"/>
   
        <many-to-one name="type" class="model.UserType" foreign-key="id"/>
       
      <one-to-one name="picture" class="model.UserPicture" cascade="delete"/>
       
        <set name="ownedProjects" table="projects">
           <key column="nickname"/>
           <many-to-many class="model.Project" column="pid" unique="true"/>
        </set>
       
        <set name="activeProjects" table="projects">
         <key column="nickname"/>
           <many-to-many class="model.Project" column="pid" unique="true"/>
        </set>
       
        <set name="ownedBugs" table="bugs">
           <key column="nickname"/>
           <many-to-many class="model.Bug" column="id" unique="true"/>
        </set>
       
        <set name="fixedBugs" table="bugs">
           <key column="nickname"/>
           <many-to-many class="model.Bug" column="id" unique="true"/>
        </set>
       
    </class>

<class name="model.BugImportancy" table="bugimportancies">
        <id name="id" >
           <generator class="native">
           </generator>
        </id>
        <property name="description"/>
    </class>

<class name="model.UserPicture" table="userpictures">
        <id name="nickname" type="string">
           <generator class="assigned">
           </generator>
        </id>
        <property name="picture"/>
    </class>

<class name="model.UserType" table="usertypes">
        <id name="id" column="id">
           <generator class="native">
           </generator>
        </id>
        <property name="type"/>
</class>

Could any one point an error here or at least send me to some faq?
Thanks a lot.
Syks


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.