-->
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: Couldn't index the entities,when I updated to Spring-2.5.6
PostPosted: Fri May 22, 2009 1:12 pm 
Newbie

Joined: Fri May 22, 2009 5:22 am
Posts: 1
Could not index the entities

spring-2.5.3
hibernate-3.3.1
hibernate-annotations-3.4.0
hibernate-search-3.0.0
and so on .

my index method code is
Code:
public void manualIndex(){
      FullTextSession fullTextSession = Search.getFullTextSession(getSession());
      fullTextSession.purgeAll( CmsContent.class );
      for (CmsContent content : this.getAll()) {
         fullTextSession.index(content);
      }
      //fullTextSession.flushToIndexes();
}

It worked well. But, when I used spring 2.5.6 instead.
the code above didn't work,and did not get any error message.

I saw the source code of hibernate-search,
in method org.hibernate.search.impl.FullTextSessionImpl.index, i got that when I index some eitities ,hibernate search put them in queue,
the queue will be processed by a Lucene(Auto)FlushEventListener.
Auto, it is true when i use spring-2.5.3 ,but not in 2.5.6 .I don't know what's the problem.

by the way,if I add the code
Code:
fullTextSession.flushToIndexes();

at the end of my method, it worked, indexed sucess.

It looks like the work queue didn't flush.Is there something wrong with my configuration of spring(include hibernate and hibernate-search).
and why it worked in spring2.5.3 but not in spring2.5.6.

Here is my configuration

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"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
   default-autowire="byName">
   <aop:aspectj-autoproxy/>
   <bean
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="locations">
         <list>
            <value>classpath:jdbc.properties</value>
            <value>classpath:cache.properties</value>
            <value>classpath:mail.properties</value>
            <value>classpath:im.properties</value>
            <value>classpath:ftp.properties</value>
            <value>classpath:fileupload.properties</value>
         </list>
      </property>
   </bean>

   <bean id="dataSource"
      class="com.atomikos.jdbc.nonxa.NonXADataSourceBean">
      <property name="uniqueResourceName" value="maindb"/>
      <property name="driverClassName" value="${db.driver}"/>
      <property name="user" value="${db.username}"/>
      <property name="url" value="${db.url}"/>
      <property name="poolSize" value="${db.poolsize}"/>
      <property name="password" value="${db.password}"/>
      <property name="testOnBorrow" value="${db.testOnBorrow}"/>
      <property name="validatingQuery" value="${db.validatingQuery}"/>
   </bean>
   <!--bean id="dataSource" class="com.p6spy.engine.spy.P6DataSource">
      <constructor-arg>
         <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource">
         <property name="driverClassName" value="${db.driver}"/>
         <property name="url" value="${db.url}"/>
         <property name="username" value="${db.username}"/>
         <property name="password" value="${db.password}"/>
      </bean>
      </constructor-arg>
   </bean-->

   <!-- Connection Pool-->
   <!--bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:comp/env/jdbc/core"/>
   </bean-->
      
   <bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true" />
   <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"/>
    <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">
       <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
    </bean>
   
   <bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="lobHandler" ref="${db.defaultLobHandler}"/>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">${db.dialect}</prop>
            <prop key="hibernate.show_sql">${db.show_sql}</prop>
            <prop key="hibernate.default_schema">${db.default_schema}</prop>
            <prop key="hibernate.format_sql">true</prop>
            <prop key="hibernate.use_sql_comments">true</prop>
            <prop key="hibernate.cache.use_query_cache">
               ${db.use_query_cache}
            </prop>
            <prop key="hibernate.default_batch_fetch_size">16</prop>
            <prop key="hibernate.jdbc.fetch_size">30</prop>
            <prop key="hibernate.jdbc.batch_size">25</prop>
            <prop key="hibernate.cache.provider_class">
               ${db.cache_provider_class}
            </prop>
            <prop key="hibernate.transaction.manager_lookup_class">
               com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
            </prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
            <prop key="hibernate.search.default.indexBase">${index.path}</prop>
            <prop key="hibernate.search.default.optimizer.operation_limit.max">500</prop>
            <prop key="hibernate.search.default.optimizer.transaction_limit.max">100</prop>
         </props>
      </property>
      <property name="annotatedClasses">
         <list>
            <value>org.core.test.entity.Sequence</value>
            <value>org.core.test.entity.Users</value>
            <value>org.core.test.entity.Depts</value>
         </list>
      </property>
      <property name="eventListeners">
         <map>
            <entry key="save-update">
               <bean class="org.core.test.listeners.LocalSaveOrUpdateListener"></bean>
            </entry>
            <entry key="delete">
               <bean class="org.core.test.listeners.LocalDeleteListenter"></bean>
            </entry>
         </map>
      </property>
      <!--
      <property name="entityInterceptor">
         <bean class="org.core.test.listeners.TestInterceptor"></bean>
      </property> -->
   </bean>
   
   <bean id="hibernateTemplate"
      class="org.springframework.orm.hibernate3.HibernateTemplate">
      <property name="sessionFactory">
         <ref bean="sessionFactory" />
      </property>
   </bean>
   
   <bean id="atomikosTransactionManager"
      class="com.atomikos.icatch.jta.UserTransactionManager"
      init-method="init" destroy-method="close">
      <property name="forceShutdown" value="true" />
   </bean>

   <bean id="atomikosUserTransaction"
      class="com.atomikos.icatch.jta.UserTransactionImp">
      <property name="transactionTimeout" value="120"/>
   </bean>

   <bean id="transactionManager"
      class="org.springframework.transaction.jta.JtaTransactionManager">
      <property name="transactionManager"
         ref="atomikosTransactionManager" />
      <property name="userTransaction" ref="atomikosUserTransaction" />
   </bean>

   <aop:config proxy-target-class="true">
      <aop:advisor pointcut="execution(* org..*Service.*(..))"
         advice-ref="txAdvice" />
      <aop:advisor pointcut="execution(* org..*ServiceImp.*(..))"
         advice-ref="txAdvice" />
      <aop:advisor pointcut="execution(* org..*Manager.*(..))"
         advice-ref="txAdvice" />
      <aop:advisor pointcut="execution(* org..*ManagerImp.*(..))"
         advice-ref="txAdvice" />
      <aop:advisor pointcut="execution(* org..*Dao.*(..))"
         advice-ref="txAdvice" />
      <aop:advisor pointcut="execution(* org..*DaoImp.*(..))"
         advice-ref="txAdvice" />
   </aop:config>

   <tx:advice id="txAdvice" transaction-manager="transactionManager">
      <tx:attributes>
         <tx:method name="get*" read-only="true" />
         <tx:method name="find*" read-only="true" />
         <tx:method name="is*" read-only="true" />
         <tx:method name="*" />
      </tx:attributes>
   </tx:advice>
   
   <!--webservice-->
   <bean id="baseWebService"
      class="org.codehaus.xfire.spring.remoting.XFireExporter"
      abstract="true">
      <property name="serviceFactory" ref="xfire.serviceFactory" />
      <property name="xfire" ref="xfire" />
   </bean>
   
   <!-- freemarker config -->
   <bean id="templateEngine" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
      <property name="templateLoaderPath" value="/WEB-INF/template/"/>
      <property name="freemarkerSettings">
         <props>
            <prop key="template_update_delay">0</prop>
            <prop key="default_encoding">UTF-8</prop>
            <prop key="locale">zh_CN</prop>
         </props>
      </property>
   </bean>
   
   <context:mbean-export />
   <bean class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
      <property name="autodetect" value="true"/>
   </bean>
   
   <bean id="sequenceManager" class="org.core.dao.SequenceManager"/>
   <bean id="innerSessionInterceptor" class="org.core.dao.support.InnerSessionInterceptor" />
   
   <import resource="classpath*:META-INF/cxf/cxf.xml" />
   <import resource="classpath*:META-INF/cxf/cxf-extension-soap.xml" />
   <import resource="classpath*:META-INF/cxf/cxf-servlet.xml" />
</beans>



Top
 Profile  
 
 Post subject: Re: Couldn't index the entities,when I updated to Spring-2.5.6
PostPosted: Sat May 23, 2009 2:47 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
when using Spring you have to make sure the transaction manager is coordinating with hibernate's transaction manager;
here's a working example using JPA:
https://www.hibernate.org/441.html
look for transactionManager. I'm sure there are more posts in this forum about the same issue with examples for non-jpa configurations.

Quote:
hibernate-3.3.1
hibernate-annotations-3.4.0
hibernate-search-3.0.0

this is another problem: when using Hibernate (core) 3.3.1.GA you have to use Hibernate Search 3.1.0.GA

_________________
Sanne
http://in.relation.to/


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.