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.  [ 5 posts ] 
Author Message
 Post subject: PersistentGenericMap GetSnapshotElement InvalidCastException
PostPosted: Wed Dec 20, 2006 2:51 pm 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
NHibernate Version: NHibernate 1.2 Beta2:
Full stack trace of any exception that occurs:

[InvalidCastException: Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.Int32,XYZ]' to type 'System.Collections.Generic.IList`1[XYZ]'.]
NHibernate.Collection.Generic.PersistentGenericMap`2.GetSnapshotElement(Object entry, Int32 i) +214
NHibernate.Persister.Collection.OneToManyPersister.DoUpdateRows(Object id, IPersistentCollection collection, ISessionImplementor session) +4875

Description:

It looks like the GetSnapshotElement method is trying to cast to an IList when it should cast to an IDictionary. I looked at the PersistentMap class and noticed that it converts to an IDictionary and not an IList. Perhaps the code should look more like this:

Code:
IDictionary<TKey, TValue> sn = ( IDictionary<TKey, TValue> ) GetSnapshot();
return sn[ ((KeyValuePair<TKey, TValue>)entry).Key ];


instead of the current:

Code:
IList<TValue> sn = ( IList<TValue> ) GetSnapshot();
return sn[ i ];
[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 2:54 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Created a JIRA issue for this: http://jira.nhibernate.org/browse/NH-839


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 2:57 pm 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
I downloaded the source and made the change myself. My change appeared to fix the problem I was having. If this change is not already made what is the process for applying the change? I have not yet contributed to this project.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 3:27 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The standard way is to submit a patch by attaching it to the JIRA issue.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 3:52 pm 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
I attached the updated file. Let me know if there is anything else I need to do, or anything you need from me.


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