I write Spring
web-app using Hibernate Search 4.5.1
. When I try search it returns emty list. I think that problem in indexing. Dir for indexes was created, but after entity saving files in dir are not changing.
This is my spring config file
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<context:component-scan base-package="project"/>
<context:annotation-config/>
<jpa:repositories base-package="project" transaction-manager-ref="hibernateTransactionManager"
entity-manager-factory-ref="entityManagerFactory"/>
<bean id="entityManagerFactory" name="managerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="project"/>
<property name="dataSource" ref="postgresDataSource"/>
<property name="validationMode" value="NONE"/>
<property name="jpaProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQL81Dialect</prop>
</props>
</property>
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider"/>
</property>
</bean>
<bean id="postgresDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://localhost:5432/LabourExchange"/>
<property name="username" value="postgres"/>
<property name="password" value="123456"/>
</bean>
<bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="dataSource" ref="postgresDataSource"/>
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="hibernateTransactionManager"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="postgresDataSource"/>
<property name="packagesToScan" value="project"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.postgres.dialect}</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">8</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.search.default.directory_provider">filesystem</prop>
<prop key="hibernate.search.default.indexBase">/var/lucene/indexes</prop>
</props>
</property>
</bean>
<!--security config-->
<security:http auto-config="true" use-expressions="true">
<security:intercept-url pattern="/pages/**" access="isAuthenticated()"/>
<security:form-login
login-page="/auth/login.jsf"
default-target-url="/pages/home.jsf"
authentication-failure-url="/auth/login.jsf?status=error"/>
<security:logout logout-success-url="/hello.jsf"/>
</security:http>
<security:authentication-manager>
<security:authentication-provider user-service-ref="UserDetailsService">
</security:authentication-provider>
</security:authentication-manager>
</beans>
My entity file
@Entity
@Table(name = "resumes")
@Indexed
public class Resume {
@Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = "title")
@Field(index= Index.YES, analyze= Analyze.YES, store= Store.NO)
@NotBlank @Size(min = 10, max = 100)
private String title;
@Column(name = "text")
@Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
@NotBlank @Size(min = 50, max = 10000)
private String text;
@Column(name = "salary")
@NotNull
private double salary;
@ManyToOne(optional = false)
@JoinColumn(name = "creator_id")
private User creator;
public User getCreator() {
return creator;
}
public void setCreator(User creator) {
this.creator = creator;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}
I solved the problem by moving
to
jpaProperties
tag