-->
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.  [ 2 posts ] 
Author Message
 Post subject: Configure hibernate-search in applicationContext-hibernate
PostPosted: Thu Feb 07, 2008 9:39 am 
Newbie

Joined: Thu Feb 07, 2008 8:30 am
Posts: 7
Hi,

This is my first post here. I have a project based on appfuse-light. In this project I have a applicationContext-hibernate.xml file. My question is: how do I configure this file to use hibernate-search.

Normally in hibernate.cfg.xml these lines have to be added:

Code:
<property name="hibernate.search.default.directory_provider">
  org.hibernate.search.store.FSDirectoryProvider
</property>   
<property name="hibernate.search.default.indexBase">
  C:\lucene
</property>

<event type="post-update">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>

<event type="post-insert">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
       
<event type="post-delete">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>



How do I put these lines in my applicationContext-hibernate.xml file which looks something like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
    <description>Default datasource that uses C3PO as a pool implementation</description>
     <property name="driverClass" value="${jdbc.driverClassName}"/>
    <property name="jdbcUrl" value="${jdbc.url}"/>
    <property name="initialPoolSize"><value>10</value></property>
      <property name="minPoolSize"><value>10</value></property>
      <property name="maxPoolSize"><value>50</value></property>
     <property name="properties">
         <props>
             <prop key="user">${jdbc.username}</prop>
             <prop key="password">${jdbc.password}</prop>
         </props>
    </property>
</bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingResources">
            <list>
              <value>model/Booking.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            </props>
        </property>

    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

<bean id="bookingDao" class="dao.hibernate.BookingDaoHibernate">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

   
</beans>


Is it possible to do what I'm asking or do I have to do it in another way? Do I have to create a hibernate.cfg.xml file to get hibernate-search to work?

Thanks in advance for any answers.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 07, 2008 2:12 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi, I think this is more of a Spring configuration question than a Hibernate one, but I reckon the first to properties hibernate.search.default.directory_provider and hibernate.search.default.indexBase you could just add to the hibernate properties section.

Regarding the event listeners, I've seen this somewhere around:

Code:
<bean id="loadListener" class="org.hibernate.event.def.DefaultLoadEventListener" />
      
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="eventListeners">
         <map>
            <entry key="load"><ref local="loadListener" /></entry>
         </map>
      </property>
...
</bean>


The question is really under which key you have to add the event listeners. I would just try post-insert and post-delete, but that's just a guess.


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

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.