-->
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: Generic dictionary mapping
PostPosted: Mon Mar 19, 2007 1:14 pm 
Newbie

Joined: Mon Mar 19, 2007 1:04 pm
Posts: 1
Hi all,

I'm fairly new to NHibernate, and I'm trying to do some mappings for my object model.

I have an Item, that has a list of Properties (each one of them is an Item of its own). So far, everything went fine.
I also added a IDictionary<Property, object> called Attributes to the Item class, in order to save the values of the Properties that the item has. I would like to save the Items in one class, and the PropertiesValues in another class.

The structure of the PropertiesValues table should be:
Code:
ItemId : uniqueidentifier
PropertyId : uniqueidentifier
Value : binary(100)


Bellow is the mapping file I tried to use:

Code:
<hibernate-mapping>
  <class name="IInfoItem" table="InfoItem" lazy="false" discriminator-value="IInfoItem">
    <id name="Id">
      <column name="Id" sql-type="uniqueidentifier" not-null="true"/>
      <generator class="guid.comb" />
    </id>
    <discriminator column="Type" type="string"/>
    <property name="DisplayName" not-null="true" />
    <property name="Version" not-null="true" />
   
    <many-to-one name="Parent" column="ParentId" />
    <bag name="Children" inverse="true" lazy="true">
      <key column="ParentId"/>
      <one-to-many class="InfoItem"/>
    </bag>

    <map name="Attributes" table="ItemAttributes" generic="true" collection-type="System.Collections.Generic.Dictionary`2[[D3.DomainModel.Property, D3.DomainModel], [System.Object, mscorlib]], mscorlib">
      <key column="ItemId" />
      <index-many-to-many column="PropertyId" class="Property" />
      <element column="Value" type="Serializable" />
    </map>

    <subclass name="InfoItem" lazy="false" discriminator-value="InfoItem">
    </subclass>
    <subclass name="Property" lazy="false" discriminator-value="Property">
    </subclass>
  </class>
</hibernate-mapping>


When I'm trying to add the assembly to the Configuration, I get an exception saying "Custom type does not implement UserCollectionType".
The error message itself is pretty straight forward, and easy to understand. However, I don't fully understand what exactly I'm suppose to do in this scenario.

Can anyone assist with this?

Hibernate version: 1.2.0.3001
Code:
Code:


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.