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