-->
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.  [ 3 posts ] 
Author Message
 Post subject: <index> <many-to-many> map to IDictionary troubl
PostPosted: Fri Sep 16, 2005 1:07 pm 
I'm just curious if there is a mapping work around to problem described below.

Given the following schema:
    Table: List
    PK - ListName
    ...

    Table: Attribute
    PK - AttributeName
    ...

    Table: ListAtt
    PK, FK1 - ListName
    PK, FK2 - AttributeName

And the following mapping:

Code:
<class name="AppList, ApplicationLists.ORM" table="List">
...
  <map name="Attributes" table="ListAtt" >
   <key column="ListName"/>
   <index column="AttributeName" type="String"/>
   <many-to-many column="AttributeName" column="AttributeName" class="Attribute, ApplicationLists.ORM"/>
  </map>
...
</class>

I run into the following exception:
failed: System.Xml.XmlException : 'column' is a duplicate attribute name.

I have also tried the following mapping for the same AppList class mapping:
Code:
<map name="Attributes" table="ListAtt">
   <key column="ListName"/>
   <index-many-to-many column="AttributeName" class="Attribute, ApplicationLists.ORM"/>
</map>

With it I run into the following exception:
failed: NHibernate.MappingException : The element 'urn:nhibernate-mapping-2.0:map' has incomplete content. Expected 'urn:nhibernate-mapping-2.0:element urn:nhibernate-mapping-2.0:one-to-many urn:nhibernate-mapping-2.0:many-to-many urn:nhibernate-mapping-2.0:composite-element urn:nhibernate-mapping-2.0:many-to-any'.

I know the solution may be to add an index column to the ListAtt table, but it seems like this is a very common implementation without having to do so. I would think that there should be, or potentially is, a way to implement an IDictionary collection with the <map> element using the foreign key as both the relationship mapping and the index mapping. In my case implementing an index column would introduce redundant data in the table. Please advise. Thanks in advance for any help.

nathan


Top
  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 2:06 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You have column attribute specified twice in your first extract, hence the error.


Top
 Profile  
 
 Post subject: RE
PostPosted: Fri Sep 16, 2005 2:35 pm 
Sorry for that.

The first snippet should actually be...
Code:
<map name="Attributes" table="ListAtt" >
   <key column="ListName"/>
   <index column="AttributeName" type="String"/>
   <many-to-many column="AttributeName" class="Attribute, ApplicationLists.ORM"/>
</map>


And the exception:
failed: NHibernate.MappingException : Repeated column in mapping for collection: ApplicationLists.ORM.List.Attributes column: AttributeName


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.