Hello *,
the situation is as follows. When i start the application, the index folders get created. If i place wrong Search Annotations i get errors, so this part seems to be okay.
But when i start the indexing process i don't get errors, but although the entities don't get indexed.
Even other Transactions are handled without errors and work properly, only indexing fails.
I found these, but don't get it:
https://forum.hibernate.org/viewtopic.php?f=9&t=996131&hilit=index+entity+springhttp://forum.springsource.org/showthread.php?t=67651https://www.hibernate.org/441.htmlI would be glad if some of you have a look on the configuration files and give me a hint how to solve this.
Thx
**********
hibernate-search 3.1.0.GA
hibernate-core 3.3.1.GA
lucene-core 2.4.1
hibernate-commons-annotations 3.0.0.GA
solr-common 1.3.0
solr-core 1.3.0
apache-solr-analyzer 1.2.0
org.springframework.core 2.5.6.A
org.springframework.webflow 2.0.7.RELEASE
etc.
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:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.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.5.xsd">
<!-- DATA SOURCE DEFINITION [oracle] -->
<bean id="dataSourceTarget" autowire-candidate="false"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/XXX" />
<property name="resourceRef" value="true" />
</bean>
<bean id="userContextAwareDataSourceProxy"
<!-- entends org.springframework.jdbc.datasource.DelegatingDataSource-->
class="XXX.common.spring.jdbc.UserContextAwareDataSourceProxy"
autowire-candidate="false">
<property name="targetDataSource" ref="dataSourceTarget" />
<property name="contextAware">
<bean class="XXX.common.spring.jdbc.SpringSecurityUserContext" />
</property>
<property name="userContextDAO">
<bean class="XXX.common.spring.jdbc.FUserContextDAO" />
</property>
</bean>
<!-- Context aktiviert -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<property name="targetDataSource" ref="userContextAwareDataSourceProxy" />
</bean>
<!-- Hibernate Session-Factory -->
<bean id="sessionFactory"
class="XXX.common.spring.hib.ContextAwareSessionFactoryBean" <!--
depends-on="dataSource">
<property name="initContextAware">
<bean class="XXX.common.spring.jdbc.SimpleSecurityUserContext">
<property name="userName" value="INIT" />
</bean>
</property>
<property name="useTransactionAwareDataSource" value="true" />
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="configLocations">
<list>
<!--
<value>classpath:*-hibernate.cfg.xml</value>
<value>classpath*:META-INF/hib-common-hibernate-dao.cfg.xml</value>
-->
<value>classpath*:META-INF/hib-*.cfg.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.session_factory_name">null</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<!-- a PlatformTransactionManager is still required -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
Code:
public class ManualIndexerDao {
...
public void indexEntityList(List<Object> list) {
Session session = getSessionFactory().getCurrentSession();
FullTextSession fullTextSession = Search
.getFullTextSession(session);
fullTextSession.setFlushMode(FlushMode.MANUAL);
fullTextSession.setCacheMode(CacheMode.IGNORE);
for (Object entity : list) {
fullTextSession.index(entity);
}
fullTextSession.flushToIndexes();
fullTextSession.clear();
}
}
Code:
public class ManualIndexerSvc {
private ManualIndexerDao dao;
private int batchSize = 1000;
@Transactional
public void indexAll(Class clazz) {
int anzahlZeilen = dao.getAllRowsCount(clazz);
int index = 0;
while (index < anzahlZeilen) {
List<Object> list = dao.findAll(clazz, null, index, batchSize);
//returns db rows from index to index+batchSize
dao.indexEntityList(list);
index += batchSize;
}
}
}
Code:
@Indexed
public class Test extends Serializable{
public static final String PROPERTY_ID = "id";
@GeneratedValue(generator="id")
@Id
protected Long id;
@Column
@Field
private String test;