views:

809

answers:

3

I'm using Hibernate for a Java-based Web Application and want to add full-text search via Compass. Compass is supposed to support that, but fails to provide any useful Getting Started guide.

I could figure out that I have to annotate my Entities with @Searchable and the various @SearchableXXX variations and accessing Compass in my service code via HibernateHelper.getCompass(sessionFactory).

I end up with a HibernateException saying "Compass event listeners not configured, please check the reference documentation and the application's hibernate.cfg.xml".

The reference documentation again hints and hibernate.cfg.xml, while I configure Hibernate with Spring's AnnotationSessionFactoryBean. For that case, the documetantation mentions: "If Hibernate Annotations or Hibernate EntityManager (JPA) are used, just dropping Compass jar file to the classpath will enable it (make sure you don't have Hibernate Search in the classpath, as it uses the same event class name)." That doesn't work for me.

Any ideas whats I'm missing or a good resource for getting started?

A: 

The best resource to review would be to check the petclinic example provided with the compass distribution (with dependencies). If by default the listener is not configured then you will have to set the EventListener.

Varun Mehta
A: 

There are two modes for Compass to integrate with Hibernate. The embedded mode basically means that you need to drop the Compass jar into the application (and possibly need to configure event listeners, depending on the Hibernate version), then you need to at least at a property configuration in your Hibernate cfg file that configures Compass index location. Here is a link link for more information.

The other option is configuring Compass to integrate with Hibernate externally, by creating a CompassGps and a Hibernate device (initialized with Hibernate SessionFactory). The Hibernate device will automatically register the relevant listeners with Hibernate. More information can be found link here.

I had that exact link in my question already, and it doesn't look like it changed much since I posted the question. Didn't really help.A full example of the Hibernate-with-Annoations setup would be useful.
Jörn Zaefferer
+1  A: 

I'm wondering why you chose Compass to go Hibernate. We looked at Compass and Hibernate-Search and we chose the latter as it has excellent integration.

You can query the test index in exactly the same way you do an SQL database with HQL or Critera.

If you were using iBatis or JDBC then Compass would of course be the better fit. Hibernate search is a better fit with JTA.

Is it me or is Compass suffering from a distinct lack of activity?

Kango_V
That's what we ended up with anyway. Therefore marking as the accepted answer...
Jörn Zaefferer