Hi,
I am trying to use the mass indexer as outlined here:
http://docs.jboss.org/hibernate/search/ ... ml_single/ :
Example 1.6. Using Hibernate Session to index data
FullTextSession fullTextSession = Search.getFullTextSession(session);
fullTextSession.createIndexer().startAndWait();
My question is how, using Spring 2.5, do I inject the session factory into the spring-managed class that contains this code?
This is my class:
@Transactional
public class ManualIndexer {
private static final Logger LOGGER = Logger.getLogger(ManualIndexer.class.getName());
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public void index() {
LOGGER.info("Indexing everything in the DB...");
StopWatch timer = new StopWatch();
Session session = SessionFactoryUtils.getSession(sessionFactory, false);
FullTextSession fullTextSession = Search.getFullTextSession(session);
try {
timer.start();
fullTextSession.createIndexer().startAndWait();
timer.stop();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
fullTextSession.close();
}
LOGGER.info("Finished indexing after: " + timer.getLastTaskTimeMillis() + "ms");
}
}
Many thanks
Jay