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>