-->
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.  [ 3 posts ] 
Author Message
 Post subject: [SOLVED]"getting started" guide of HIBERNATE SEARC
PostPosted: Thu Nov 20, 2008 2:59 pm 
Beginner
Beginner

Joined: Tue Feb 12, 2008 3:53 pm
Posts: 38
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2008 8:31 am 
Beginner
Beginner

Joined: Tue Feb 12, 2008 3:53 pm
Posts: 38
sorry about that post. I made a mistake in my application, now it is working fine


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2008 9:53 am 
Beginner
Beginner

Joined: Tue Feb 12, 2008 3:53 pm
Posts: 38
sorry about that post. I made a mistake in my application, now it is working fine


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.