Cannot use multiple listeners for the same event type

Description

Hi!

I'm trying to attach multiple listeners to the same event type (NH is
prepared for that, as i saw in the source)

It seems, that only the last one get attached, if i do it like this:

<session-factory>
...
<listener class="SomeNamespace.Listener1, SomeAssembly" type="flush"/

<listener class="SomeNamespace.Listener2, SomeAssembly" type="flush"/

...
</session-factory>

Ok, no problem, i figured out, it can be done other way:

<session-factory>
...
<event type="flush">
<listener class="SomeNamespace.Listener1, SomeAssembly"/>
<listener class="SomeNamespace.Listener2, SomeAssembly"/>
</event>
...
</session-factory>

Not much better, as i get a 'Unrecognized listener type
[NotValidType]' exception.

I tracked down, it could be a bug in the Configuration class, where it
try to configure sessionfactory's listeners from an
IHibernateConfiguration instance.
Listener1 and Listener2 appears in the hc.SessionFactory.Events and
hc.SessionFactory.Listeners collections too, when it should be only in
hc.SessionFactory.Events, I guess.
I dared go further, and found that those collections are initialized
by SessionFactoryConfiguration's ParseListeners and ParseEvents
methods. They use XPaths from CfgXmlHelper, like "//cfg:session-
factory//cfg:event" and "//cfg:session-factory//cfg:listener" where "//
cfg:listener" means, it will find any element in the tree, not only
direct childen.
So, I think the proper expression should be "//cfg:session-factory/
cfg:listener".

thanks,

dcd

(copypasted from nhures list)

Environment

None

Activity

Show:

Fabio Maulo June 19, 2008 at 10:32 AM

The fix prevent some other issue.
Thanks.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created June 18, 2008 at 12:25 PM
Updated June 19, 2008 at 10:32 AM
Resolved June 19, 2008 at 10:32 AM
Who's Looking?