1 Reply Latest reply on Jan 10, 2008 8:16 AM by mars1412

    configuration of hiberante events

    mars1412 Apprentice

      I am trying to create some eventlisteners for hibernate:
      http://www.hibernate.org/hib_docs/reference/en/html/events.html#objectstate-events
      but my listeners seem not to fire.

      I think, it's just a configuration issue.

      I created a simple listener, by overriding the default hibernate update event listener:

      public class HibernateUpdateEventListener extends DefaultUpdateEventListener {
       @Override
       public void onSaveOrUpdate(SaveOrUpdateEvent event) {
       System.err.println("update-event listener fired");
      
       super.onSaveOrUpdate(event);
       }
      }
      


      the configuration in my hibernate.cfg.xml file:
       <event type="update">
       <listener class="com.twentyfouract.web.session.util.HibernateUpdateEventListener"/>
       </event>


      this file will be located in my.ear/my.jar/hibernate.cfg.xml (in the same direcotry, as the seam.properties file)
      • is this the correct place fo the hibernate.cfg.xml file?
      • do I need some other configuration?
      • might this intefere with some other configuration files, like persistence.xml, ejb-jar.xml?

        When I now call update() the entity, I expect the message to be written to stderr, which does not happen.
        the entity values in the database have changed, but the logmessage does not show up

        I also tried the same with DefaultSaveEventListener and calling em.persist() which creates a new entity in the database, but does not show my events logmessage

        maybe it's just some configuration problem - I am using SEAM: see also my original post in the SEAM forum:
        http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118460#4118460