Hibernate Search
scope_talka May 30, 2011 4:11 PM^Can someone help with the following problem(Hibernate Search)? I keep getting bunch of errors every time I run the app. Here is the class.
-------------------------------------------------------------------------------------------------------------------------------------------
@Name( "userDao" )
@Scope( ScopeType.STATELESS )
@AutoCreate
public class UserDAO {
private final EntityManager em;
@In FullTextEntityManager fem;
public UserDAO() {
em = ( EntityManager )Component.getInstance( "entityManager", true );
}
@SuppressWarnings( "unchecked" )
public List<User> searchUsers( final String text ) {
final Query query;
try {
FullTextEntityManager fem = Search.getFullTextEntityManager( em );
query = fem.createFullTextQuery( getLuceneQuery( text ), User.class );
return query.getResultList();
} catch ( ParseException ex ) {
log.error( "search error", ex );
return null;
}
}
private org.apache.lucene.search.Query getLuceneQuery( final String queryString ) throws ParseException {
try {
Map<String, Float> boostPerField = new HashMap<String, Float>( 2 );
boostPerField.put( "subject", (float) 4 );
boostPerField.put( "description", (float) 1 );
String[] searchFields = { "subject", "description" };
QueryParser parser = new MultiFieldQueryParser( Version.LUCENE_31, searchFields, new StandardAnalyzer( Version.LUCENE_31 ), boostPerField );
parser.setDefaultOperator( QueryParser.Operator.OR );
org.apache.lucene.search.Query luceneQuery = null;
luceneQuery = parser.parse( queryString );
return luceneQuery;
} catch ( ParseException ex ) {
return null;
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------------
Basially, injecting the FullTextEntityManager isn't working, I need the method(searchUsers) to return list of user objects and when I run the app I get the following error.
( @In attribute requires non-null value: userDao.fem )
someone please help!!!
^