-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate search: update-insert-delete events not firing
PostPosted: Wed Oct 08, 2008 9:57 am 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
Hi,

I'm using Hibernate/Spring through Appfuse and since Appfuse "hides" the sessionFactory, I have to use some tricks to register the search event handlers. However, it seems that this works. Debugging it, I can see that they are registered but they are not firing. I think this is because Appfuse uses the merge method to save objects and these dont seem to fire the insert/update events?

Hibernate version:3.2.6.ga


Code:
public class HibernateExtensionPostProcessor extends
        org.appfuse.dao.spring.HibernateExtensionPostProcessor {

        private Map eventListeners;
        private String sessionFactoryBeanName = "sessionFactory";

        /**
         * Top level properties to add to the session factory.
         *
         * @param eventListeners
         *            The list of additional properties.
         */
        public void setEventListeners(Map eventListeners) {
                this.eventListeners = eventListeners;
        }

        @SuppressWarnings("unchecked")
        public void postProcessBeanFactory(
                ConfigurableListableBeanFactory configurableListableBeanFactory) {
                if (configurableListableBeanFactory
                        .containsBean(sessionFactoryBeanName)) {
                        BeanDefinition sessionFactoryBeanDefinition = configurableListableBeanFactory
                                .getBeanDefinition(sessionFactoryBeanName);
                        MutablePropertyValues propertyValues = sessionFactoryBeanDefinition
                                .getPropertyValues();

                        if (eventListeners != null) {
                                PropertyValue propertyValue = propertyValues
                                        .getPropertyValue("eventListeners");

                                if (propertyValue == null) {
                                        propertyValue = new PropertyValue("eventListeners",
                                                new HashMap());
                                        propertyValues.addPropertyValue(propertyValue);
                                }

                                // loop over properties List and add top level property for each entry
                                Map existingListeners = (Map) propertyValue.getValue();
                                existingListeners.putAll(eventListeners);
                        }
                }
        }
}


Code:
<bean id="textIndexEventListener"
                class="org.hibernate.search.event.FullTextIndexEventListener" />

        <bean
                class="nl.myproject.dao.hibernate.HibernateExtensionPostProcessor">
                <property name="eventListeners">
                        <map>
                                <entry key="post-update"><ref local="textIndexEventListener" /></entry>
                                <entry key="post-insert"><ref local="textIndexEventListener" /></entry>
                                <entry key="post-delete"><ref local="textIndexEventListener" /></entry>
                        </map>
                </property>
        </bean>



Any idea why the events are firing?

Cheers.
Marc
[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.