Discussion:
Net4Collections throwing Error
Action Jackson
2011-08-31 04:52:05 UTC
Permalink
Hi all,

I'm using Jose's Net4Collections classes to get NHibernate to work
with the collections built into the .NET framework. I'm getting an
error that I can't decipher. It appears to be blowing up in the
'GetDeletes' method of the PersisentGenericSet class. I'm not sure
why GetDeletes is even called since I'm not trying to delete anything.

Unable to cast object of type
'SetSnapShot`1[Content.Base.Category,System.Object]' to type
'ISetSnapshot`1[Content.Base.Category,Content.Base.Category]'.

Here's the Category class:

public class Category:DomainObject
{
public virtual Category ParentCategory { get; set; }
public virtual ISet<Category> ChildCategories { get; protected
set; }

public virtual void AddChildCategory(Category category)
{
category.ParentCategory = this;
ChildCategories.Add(category);
}
}

The error occurs when I try to persist like so:

using (new UnitOfWorkScope())
{
Category parentCategory = _categoryRepository.Get(x => x.Name ==
"Mathematics");
parentCategory.AddChildCategory(new Category("child"));
_categoryRepository.Add(parentCategory);
}

Here's a portion of the stack trace:

at
Infrastructure.Implementations.Data.PersistentGenericSet`1.GetDeletes(ICollectionPersister
persister, Boolean indexIsFormula) in Net4Collections.cs: line 619
at
NHibernate.Persister.Collection.AbstractCollectionPersister.DeleteRows(IPersistentCollection
collection, Object id, ISessionImplementor session)
at NHibernate.Action.CollectionUpdateAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource
session)
at
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent
event)
at NHibernate.Impl.SessionImpl.Flush()

Any ideas?? Thanks!
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhusers-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to nhusers+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
Action Jackson
2011-08-31 05:14:09 UTC
Permalink
I should mention that _categoryRepository.Add() simply calls
Session.SaveOrUpdate(entity) and I'm using NHibernate 3.2.0.4000
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhusers-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to nhusers+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
Action Jackson
2011-08-31 06:38:44 UTC
Permalink
I found the solution. Turns out this bug was fixed a couple days
ago.
Post by Action Jackson
I should mention that _categoryRepository.Add() simply calls
Session.SaveOrUpdate(entity) and I'm using NHibernate 3.2.0.4000
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhusers-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to nhusers+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
Luiz Zen
2018-04-04 17:24:30 UTC
Permalink
Hi,
This is an old post, but I am having the same issue.
Was this a bug in NHibernate or in the Net4Collections class?
Which version fixes it?

Thanks
Post by Action Jackson
I found the solution. Turns out this bug was fixed a couple days
ago.
Post by Action Jackson
I should mention that _categoryRepository.Add() simply calls
Session.SaveOrUpdate(entity) and I'm using NHibernate 3.2.0.4000
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Loading...