1 Reply Latest reply on Nov 1, 2006 3:31 AM by jilles

    Lucene indexing + Entity beans

    sergiu72

      I'm trying to use the Lucene annotations @Indexed, @Keyword, @Text to annotate my EJB3 entity beans for indexing.

      I need to add;


      <hibernate-configuration>
      ...
      <event type="post-commit-update"


      <event type="post-commit-insert"


      <event type="post-commit-delete"


      </hibernate-configuration>

      To an xml file but I don't know where to put it?

      I'm running the EJB3's in standalone/embedded mode while testing.

      many thanks

        • 1. Re: Lucene indexing + Entity beans
          jilles

           

          "sergiu72" wrote:
          I'm trying to use the Lucene annotations @Indexed, @Keyword, @Text to annotate my EJB3 entity beans for indexing.

          I need to add;


          <hibernate-configuration>
           ...
           <event type="post-commit-update"
           <listener
           class="org.hibernate.lucene.event.LuceneEventListener"/>
           </event>
           <event type="post-commit-insert"
           <listener
           class="org.hibernate.lucene.event.LuceneEventListener"/>
           </event>
           <event type="post-commit-delete"
           <listener
           class="org.hibernate.lucene.event.LuceneEventListener"/>
           </event>
          </hibernate-configuration>


          To an xml file but I don't know where to put it?

          I'm running the EJB3's in standalone/embedded mode while testing.

          many thanks


          I had a go at this yesterday and managed to get it to work. The xml bit you quote is from the hibernate configuration. If you are using ejb3, you will probably be using persistence.xml which is also the place pass hibernate specifics.

          I provided these properties (in addition to the usual stuff) to get lucene going.

          <property name="hibernate.lucene.default.directory_provider" value="org.hibernate.lucene.store.FSDirectoryProvider" />
           <property name="hibernate.lucene.default.indexBase" value="c:/testindex" />
           <property name="hibernate.ejb.event.post-insert" value="org.hibernate.ejb.event.EJB3PostInsertEventListener, org.hibernate.lucene.event.LuceneEventListener" />
           <property name="hibernate.ejb.event.post-update" value="org.hibernate.ejb.event.EJB3PostUpdateEventListener, org.hibernate.lucene.event.LuceneEventListener" />
           <property name="hibernate.ejb.event.post-delete" value="org.hibernate.ejb.event.EJB3PostDeleteEventListener, org.hibernate.lucene.event.LuceneEventListener" />


          I couldn't get things to work in jboss 4.0.4 because that uses an older pre release version of hibernate. Upgrading to 4.0.5 fixed things for me. Note that you need to specify indexBase rather than indexDir (as the documentation still claims). Also you need to be sure to include the default EJB3 listenerers if you override these settings.

          Other than that, all I did was dump the lucene 2.0 jar file in the lib dir of my server and (i.e. default/lib) and add some annotations similar to those in the hibernate lucene manual.