-->
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.  [ 2 posts ] 
Author Message
 Post subject: Help: composite-id link table problem
PostPosted: Fri Oct 20, 2006 11:57 am 
Newbie

Joined: Fri Oct 20, 2006 11:31 am
Posts: 1
Hello,

I have a mapping problem with 3 tables:

Organization(OrganizationID)
Address(AddressID)
OrganizationAddress(OrganizationID, AddressID)

My mapping is:
Organization

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Entities" namespace="Entities">
<class name="Entities.Organization, Entities" table="ORGANIZATION">
<id name="ID" column="ID" type="System.Int32">
<generator class="assigned"/>
</id>
<property name="ID" column="ID" type="System.Int32" update="false" insert="false" />
<property name="Name" column="Name" type="System.String" update="true" insert="true" />
<list name="OrganizationAddress" inverse="true">
<key column="OrganizationID" />
<index column="OrganizationID" />
<one-to-many class="OrganizationAddress" />
</list>
</class>
</hibernate-mapping>



Address

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Entities" namespace="Entities">
<class name="Entities.Address, Entities" table="ADDRESS">
<id name="ID" column="ID" type="System.Int32">
<generator class="assigned"/>
</id>
<property name="ID" column="ID" type="System.Int32" update="false" insert="false" />
<property name="Street" column="Street" type="System.String" update="true" insert="true" />
<property name="Number" column="Number" type="System.String" update="true" insert="true" />
<list name="OrganizationAddress" inverse="true">
<key column="AddressID" />
<index column="AddressID" />
<one-to-many class="OrganizationAddress" />
</list>
</class>
</hibernate-mapping>


OrganizationAddress

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Entities"

namespace="Entities">
<class name="Entities.OrganizationAddress, Entities"

table="ORGANIZATION_ADDRESS">
<composite-id>
<key-property name="OrganizationID" column="OrganizationID" type="System.Int32" />


<key-property name="AddressID" column="AddressID" type="System.Int32" />
<key-many-to-one name="Organization" column="OrganizationID" />
<key-many-to-one name="Address" column="AddressID" />
</composite-id>
</class>
</hibernate-mapping>


I receive the error: Repeated column in mapping for collection:

Entities.Address.OrganizationAddress column: AddressID



Please HELP ME!
What is wrong in my mapping?

Thanks,
joxx


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 3:51 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
In OrganizationAddress, you madded AddressId twice.
You need to remove one of those or marked it with update/insert =false


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.