Hi,
hibernate-search-3.0.1GA.jar
hibernate-entitymanager-3.3.2GA.jar
spring-core-3..0.1RELEASE.jar
I am facing a problem in automatic indexing,My manuall indexing is working fine, but when new record is saved through hql it does not come into the search result. although it should come, as in hibernate search update the lucene index with every new insert , update and delete.
relevant configuration file is as follow:
applicationContext.xml
Code:
<!-- Hibernate session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="use_outer_join">${hibernate.use_outer_join}
</prop>
<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}
</prop>
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider}
</prop>
<prop key="hibernate.connection.pool_size">10</prop>
<prop key="hibernate.jdbc.batch_size">30</prop>
<prop key="hibernate.c3p0.timeout">30000</prop>
<prop key="hibernate.connection.release_mode">after_statement</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
<prop key="hibernate.search.default.indexBase">C:/var</prop>
<prop key="org.hibernate.worker.execution">async</prop>
</props>
</property>
<property name="eventListeners">
<map>
<entry key="post-update" value-ref="searchListener" />
<entry key="post-insert" value-ref="searchListener" />
<entry key="post-delete" value-ref="searchListener" />
</map>
</property>
.....
<!-- search -->
<bean id="searchListener" class="org.hibernate.search.event.FullTextIndexEventListener" />
HibernateSearchUtil.java
Code:
/**
This method builds the lucene index
public void createIndex(Class cls,Session session){
try{
String clsName = cls.getName();
List list = session.createQuery("from "+clsName).list();
FullTextSession fullTextSession = Search.createFullTextSession(session);
Transaction tx = fullTextSession.beginTransaction();
Iterator it = list.iterator();
while(it.hasNext())
{
Object obj = it.next();
fullTextSession.index(obj);
}
tx.commit();
System.out.println(clsName + " has been indexed !");
}
catch(Exception exp){exp.printStackTrace();}
}
any help would be appriciated.
thanks
Code: