I have begun to implement HIBERNATE SEARCH in my application, following the online "getting started" guide (
http://www.hibernate.org/hib_docs/searc ... search.pdf )
I have followed the next steps :
1) I downloaded the JAR and put them in the classpath of ECLIPSE
2) I mapped a class :
Code:
@Indexed
public class User implements UserDetails {
/**
* User's ID
*/
@DocumentId
protected long userId;
/**
* The User's Login
*/
@Field(index=Index.TOKENIZED, store=Store.NO)
protected String username;
}
3) I added the following properties in the hibernate.properties file
Code:
#the default directory provider
hibernate.search.default.directory_provider = org.hibernate.search.store.FSDirectoryProvider
#the default base directory for the indecies
hibernate.search.default.indexBase =/Users/xflamant/lucene/indexes
4) I ran the following JUNIT test (it ran well) :
Code:
Session session = SessionFactoryUtils.getSession(sessionFactory, true);
FullTextSession fullTextSession = Search.createFullTextSession(session);
Transaction tx = fullTextSession.beginTransaction();
List<User> users = session.createQuery("from User as user").list();
for (User user : users) {
fullTextSession.index(user);
}
tx.commit();
Normally, I should have an index appearing in my directory /Users/xflamant/lucene/indexes, but I got nothing
I don't know where I made a mistake.
Here is my configuration : hibernate 3.2.2, the mapping is automaticaly generated with XDOCLET tags and I have my "hbm" configuration files. Here is an extract that concerns my case :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="com.framework.model.users.User"
table="USERS"
>
<id
name="userId"
column="userId"
type="long"
unsaved-value="null"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-User.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="username"
type="java.lang.String"
update="true"
insert="true"
column="username"
not-null="true"
unique="true"
/>
</hibernate-mapping>
One thing astonish me : I don't specify the HIBERNATE SEARCH annotated class in configuration files. Is it normal ? Thank you for your help