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: IGNORE - solved
PostPosted: Thu Apr 17, 2008 11:29 am 
Newbie

Joined: Thu Apr 17, 2008 11:12 am
Posts: 1
I have a many to many mapping based on the documentation. I cannot get it to work at all. I am getting the error message:

Foreign key in table LicensedFeatures must have same number of columns as referenced primary key in table Configurations

Configurations has a primary key called Id
Features has a primary key called Id
The mapping table LicensedFeatures has two columns: ConfigurationId and FeatureId. These have foreign key constraints to the Id columns in the other tables.

My mapping files look like this:

Configuration.hbm.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="ActivationAdmin" assembly="ActivationAdmin">
<class name="Configuration" table="Configurations">
<id name="Id" type="Int64" column="Id" unsaved-value="0">
<generator class="identity"/>
</id>
<set name="LicensedFeatures" lazy="true" table="LicensedFeatures">
<key column="ConfigurationId"/>
<many-to-many class="Feature" column="FeatureId"/>
</set>
</class>
</hibernate-mapping>

Feature.hbm.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="ActivationAdmin" assembly="ActivationAdmin">
<class name="Feature" table="Features">
<id name="Id" type="Int64" column="Id" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="FeatureName" column="FeatureName" length="50" not-null="true" />
</class>
</hibernate-mapping>


When I try and use this I get an exception saying:

Foreign key in table LicensedFeatures must have same number of columns as referenced primary key in table Configurations

I am tearing my hair out.


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.