0 Replies Latest reply on Jan 24, 2006 7:34 AM by nigelwhite

    Configuring hibernate event listeners with a hibernate.ejb.c

    nigelwhite

      I have the following line in my persistence.xml:

       <property name="hibernate.ejb.cfgfile" value="hibernate_config.xml"/>
      


      In hibernate_config.xml, I have:

      <?xml version='1.0' encoding='utf-8'?>
      <!DOCTYPE hibernate-configuration PUBLIC
       "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
       "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
       <hibernate-configuration>
       <session-factory>
       <event type="save-update">
       <listener class="com.fcl.util.HibernateEventListener"/>
       </event>
       <event type="pre-update">
       <listener class="com.fcl.util.HibernateEventListener"/>
       </event>
       <event type="post-commit-update">
       <listener class="com.fcl.util.HibernateEventListener"/>
       <listener class="org.hibernate.lucene.event.LuceneEventListener"/>
       </event>
       <event type="post-commit-insert">
       <listener class="com.fcl.util.HibernateEventListener"/>
       <listener class="org.hibernate.lucene.event.LuceneEventListener"/>
       </event>
       <event type="post-commit-delete">
       <listener class="com.fcl.util.HibernateEventListener"/>
       <listener class="org.hibernate.lucene.event.LuceneEventListener"/>
       </event>
       </session-factory>
       </hibernate-configuration>


      So, I want to have my own listener on the pre-update event.

      The way JBoss configures its hibernate session factory overwrites setting from hibernate_config.xml

      It processes hibernate_config.xml first, and sets the listeners, but then JBoss has to do its own configuration for its own purposes.

      The way hibernate event listeners are set is that you pass an array of listener objects to associate with a certain event.

      This array becomes the new listener set. They are not added - all previous listeners are lost.

      So JBoss is overwriting some configuration settings.

      IMHO, this is a bug. I cannot configure Hibernate as I require.

      In the absence of an addBlahEventListener() call in hibernate, surely JBoss, should tread more carefully by getting the listener array, copying it into a new array, adding its own to the end (or the beginning - whatever), and then setting the listeners.

      How do I go about reporting this?