I'm trying to implement an IPostInsert/UpdateEventListener. What I
want to achieve is sending two SQL update queries:
void IPostUpdateEventListener.OnPostUpdate(PostUpdateEvent @event)
{
/*
* Getting left and right ommited
*/
@event.Session.CreateSQLQuery("update categories c set
isbranchactive = 1 where c.lft >= :lft and c.rgt <= :rgt")
.SetInt64("lft", left)
.SetInt64("rgt", right)
.ExecuteUpdate();
}
Nothing special. The problem is it blows up when commiting a
transaction:
[InvalidOperationException: Collection was modified; enumeration
operation may not execute.]
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource
resource) +56
System.Collections.Generic.Enumerator.MoveNextRare() +58
System.Collections.Generic.Enumerator.MoveNext() +93
NHibernate.Engine.ActionQueue.ExecuteActions(IList list) +149
NHibernate.Engine.ActionQueue.ExecuteActions() +32
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource
session) +253
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent
event) +97
NHibernate.Impl.SessionImpl.Flush() +275
NHibernate.Transaction.AdoTransaction.Commit() +236
I looked into the ExecuteActions(...) and replaced foreach enumeration
with a regular for loop.
Everything seems to work just fine. Tests are passing. I'm using NH
2.1.1 and 2.1.2.
Now my question is: is the original behavior a bug. If yes, then is
the proposed solution acceptable?
I need this order of execution and cannot use Pre* Listeners
Thanks,
Filip
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.