Collection was not processed by flush()

1,096 views
Skip to first unread message

epitka

unread,
Nov 24, 2009, 2:38:45 PM11/24/09
to nhusers
Hi,
I am getting this error when saving entity. This problem pops up only
when I have a PreUpdateEventListener registered with session factory.
In this event listener, I need to navigate the object graph, and it
may or may not lazy load collections in the parent. I am doing some
serialization of the object graph but there will be no changes to the
state of the collections, they will just be loaded. Is there a
workaround for the issue?

collection [dnnSphere.Meta.Model.MetaProject.MetaPackages] was not
processed by flush()

[AssertionFailure: collection
[dnnSphere.Meta.Model.MetaProject.MetaPackages] was not processed by
flush()]
NHibernate.Engine.CollectionEntry.PostFlush(IPersistentCollection
collection) +163
NHibernate.Event.Default.AbstractFlushingEventListener.PostFlush
(ISessionImplementor session) +516
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush
(FlushEvent event) +112
NHibernate.Impl.SessionImpl.Flush() +296
NHibernate.Transaction.AdoTransaction.Commit() +197
dnnSphere.Meta.Persistence.GenericDao.Save(T entity) in C:\Software
\SharpMod\trunk\src\Meta\dnnSphere.Meta\Persistence\GenericDao.cs:174


epitka

unread,
Nov 25, 2009, 8:31:13 AM11/25/09
to nhusers
I debugged this some more, and it does not make sense that this error
is thrown. Collection MetaPackages is a lazy loaded, and does not get
loaded during in the event listener. The only this, which when I
comment out makes this go away, is that during serialization proces, I
refer to MetaProject (a parent) for its name. That is it. It
collection of MetaPackages does not get touched at all. Is this a bug?

Revin

unread,
Dec 3, 2009, 4:05:00 AM12/3/09
to nhusers
Hi epitka,

Do you have any luck with this problem?
I got the same error message...

Thanks...

acl123

unread,
Dec 15, 2009, 2:07:50 AM12/15/09
to nhusers
Exactly the same problem here :)

epitka

unread,
Jan 8, 2010, 12:29:06 PM1/8/10
to nhusers
No, I just gave up and added a mapped field so I don't have to load
anything in PreUpdate.

kimsk112

unread,
Feb 16, 2010, 5:49:13 PM2/16/10
to nhusers
I got the same problem too. I have to remove the
PreUpdateEventListener for now.
--karlkim

allan....@gmail.com

unread,
Feb 17, 2010, 8:05:12 AM2/17/10
to nhusers
Easy fix. When configuring your session factory, replace the default
& auto flush event listeners with the classes below.

[Serializable]
public class FlushFixEventListener : DefaultFlushEventListener {

public override void OnFlush(FlushEvent @event) {
try {
base.OnFlush(@event);
}
catch (AssertionFailure) {
// throw away
}
}
}

public class AutoFlushFixEventListener :
DefaultAutoFlushEventListener {
public override void OnAutoFlush(AutoFlushEvent @event) {
try {
base.OnAutoFlush(@event);
}
catch (AssertionFailure) {

Michael diSibio

unread,
Mar 24, 2010, 7:36:48 PM3/24/10
to nhusers
Wondering if this is officially a bug and will it get fixed?

We have no listener on Flush events, only on the PostInsert/Update/
Delete and PostCollectionRecreate/Update/Remove.

We have implemented a Unit of Work pattern, in which we set FlushMode
to Never and explicitly call Flush();
Our listeners spawn an Audit transaction that occurs within a
StatelessSession.

When Flush() completes, the log shows this AssertionFailure thrown
from the AbstractFlushingEventListener.PostFlush() call on a
collection belonging to an entity that was updated.

On Feb 17, 7:05 am, "allan.ritc...@gmail.com"

> > > > > Thanks...- Hide quoted text -
>
> - Show quoted text -

Fabio Maulo

unread,
Mar 24, 2010, 7:41:04 PM3/24/10
to nhu...@googlegroups.com
Probably is Not a bug.
Are you loading a collection inside your listeners ?

2010/3/24 Michael diSibio <michael...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.




--
Fabio Maulo

Michael diSibio

unread,
Mar 25, 2010, 2:49:54 AM3/25/10
to nhusers
I loop thru the collection if and only if this condition is satisfied:

IEnumerable eventCollection = @event.Collection as IEnumerable;
if(eventCollection != null && @event.Collection.WasInitialized)
...audit
else
...skip

On Mar 24, 5:41 pm, Fabio Maulo <fabioma...@gmail.com> wrote:
> Probably is Not a bug.
> Are you loading a collection inside your listeners ?
>

> 2010/3/24 Michael diSibio <michael.disi...@gmail.com>

> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com­>


> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --

> Fabio Maulo- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages