-->
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: error with collections
PostPosted: Mon Apr 16, 2007 9:33 am 
Newbie

Joined: Tue Mar 27, 2007 6:30 am
Posts: 12
when working with collections I get the following error;

{"Unable to cast object of type 'NHibernate.Collection.PersistentSet' to type 'System.Collections.IDictionary'."}

all the examples i have seen use the .Net IDictionary type. can anyone tell me why this cast is not working?

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 16, 2007 12:16 pm 
Newbie

Joined: Mon Jul 18, 2005 9:04 am
Posts: 11
Can you post your mapping and C# file?
Maybe that'll help explaining what the problem is.


Top
 Profile  
 
 Post subject: mappings & code
PostPosted: Tue Apr 17, 2007 4:14 am 
Newbie

Joined: Tue Mar 27, 2007 6:30 am
Posts: 12
I have also tried this with bag. this I can cast into a .Net type. here's my config files and code;

NHibernate mapping file;

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="CostModelIQ.BusinessLogicLayer.ShippingAddress, BusinessLogicLayer" table="Shipto">
<id name="Identifier" column="Shipto" type="String" length="6">
<generator class="assigned" />
</id>
<property name="Customer" column="Customer"/>
<property name="Name" column="Name"/>
<property name="Variation" column="Variation"/>
<property name="AddressLine1" column="Address_Line_1"/>
<property name="AddressLine2" column="Address_Line_2"/>
<property name="City" column="City"/>
<property name="PostCode" column="Post_Code"/>
<property name="DeletedIndicator" column="Delete_Ind"/>
<property name="Ambient" column="Ambient_Destination"/>
<property name="Chilled" column="Chilled_Destination"/>
<set name="Alias" cascade="all" lazy="true">
<key column="ShipAddress"/>
<one-to-many class="CostModelIQ.BusinessLogicLayer.Alias,BusinessLogicLayer"/>

</set>
</class>
</hibernate-mapping>

The mapping file for the Alias object;

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="CostModelIQ.BusinessLogicLayer.Alias, BusinessLogicLayer" table="[Shipto Variation]">
<composite-id>
<key-property name="StorageLocation" column="Storage_Location"/>
<key-property name="ShipAddress" column ="Shipto_Variation"/>
<key-property name="AliasID" column="Shipto"/>
</composite-id>
</class>
</hibernate-mapping>


C# code;

[Serializable]
public class ShippingAddress:BaseBusinessObject
{
private IDictionary alias;
/// <summary>
/// returns a list of alternative names this shipping address is referred to by.
/// </summary>
public virtual IDictionary Alias
{
get
{

return alias;
}
set
{
alias = value;
}
}
}


Top
 Profile  
 
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.