-->
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: must have same number of columns as the referenced primary..
PostPosted: Tue Jul 27, 2004 6:51 pm 
Newbie

Joined: Tue Jun 29, 2004 6:21 pm
Posts: 2
Any suggestions on the following? Many thanks.

Hibernate Version: 2.1.4

Database: MS SQL 2000

Stack Trace:

net.sf.hibernate.MappingException: Foreign key (EntityInstanceAssociation [DataRouteId])) must have same number of columns as the referenced primary key (DataRoute [LineId,DocumentId])
at net.sf.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:60)
at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:667)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:761)
at HibernateTest.main(Unknown Source)
Exception in thread "main"

DataRoute Mapping:

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.***.DataRoute"
table="DataRoute"
>

<id
name="id"
type="java.lang.Integer"
column="Id"
>
<generator class="assigned" />
</id>

<property
name="name"
type="java.lang.String"
column="Name"
not-null="true"
length="10"
/>
...
...

<!-- Associations -->

<!-- bi-directional one-to-many association to EntityInstanceAssociation -->
<set
name="entityInstanceAssociations"
lazy="true"
inverse="true"
cascade="none"
>
<key>
<column name="DataRouteId" />
</key>
<one-to-many
class="com.***.EntityInstanceAssociation"
/>
</set>
<!-- bi-directional many-to-one association to Document -->
<many-to-one
name="document"
class="com.***.Document"
not-null="true"
>
<column name="DocumentId" />
</many-to-one>
<!-- bi-directional many-to-one association to Line -->
<many-to-one
name="line"
class="com.***.Line"
not-null="true"
>
<column name="LineId" />
</many-to-one>
<!-- bi-directional many-to-many association to DataLocation -->
<set
name="dataLocations"
lazy="true"
cascade="none"
table="EntityInstanceAssociation"
>
<key>
<column name="DataRouteId" />
</key>
<many-to-many
class="com.***.DataLocation"
>
<column name="DataLocationId" />
</many-to-many>
</set>

</class>
</hibernate-mapping>


EntityInstanceAssociation Mapping:


<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.***.EntityInstanceAssociation"
table="EntityInstanceAssociation"
>

<id
name="entityInstanceId"
type="java.lang.Integer"
column="EntityInstanceId"
>
<generator class="assigned" />
</id>

<property
name="id"
type="java.lang.Integer"
column="Id"
length="10"
/>
...

<!-- Associations -->

<!-- bi-directional one-to-one association to EntityInstance -->
<one-to-one
name="entityInstance"
class="com.***.EntityInstance"
outer-join="auto"
constrained="true"
/>
<!-- bi-directional many-to-one association to DataLocation -->
<many-to-one
name="dataLocation"
class="com.***.DataLocation"
not-null="true"
>
<column name="DataLocationId" />
</many-to-one>
<!-- bi-directional many-to-one association to DataRoute -->
<many-to-one
name="dataRoute"
class="com.***.DataRoute"
not-null="true"
>
<column name="DataRouteId" />
</many-to-one>

</class>
</hibernate-mapping>


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.