]
Sanne Grinovero reassigned HSEARCH-773:
---------------------------------------
Assignee: Nabeel Ali memon (was: Sanne Grinovero)
a volunteer :)
Example in documentation contains compilation erros
---------------------------------------------------
Key: HSEARCH-773
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-773
Project: Hibernate Search
Issue Type: Improvement
Reporter: Juraj Martinka
Assignee: Nabeel Ali memon
Fix For: 4.0.0.Alpha1
"Example 1.9. Using JPA to create and execute a search" contains compilation
errors (probably copy & paste error :) ):
http://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single...
The correct version follows:
{code}
EntityManager em = entityManagerFactory.createEntityManager();
FullTextEntityManager fullTextEntityManager =
org.hibernate.search.jpa.Search.getFullTextEntityManager(em);
em.getTransaction().begin();
// create native Lucene query unsing the query DSL
// alternatively you can write the Lucene query using the Lucene query parser
// or the Lucene programmatic API. The Hibernate Search DSL is recommended though
QueryBuilder qb = em.getSearchFactory()
.buildQueryBuilder().forEntity( Book.class ).get();
org.apache.lucene.search.Query query = qb
.keyword()
.onFields("title", "subtitle", "authors.name",
"publicationDate")
.matching("Java rocks!")
.createQuery();
// wrap Lucene query in a javax.persistence.Query
javax.persistence.Query persistenceQuery =
fullTextEntityManager.createFullTextQuery(query, Book.class);
// execute search
List result = persistenceQuery.getResultList();
em.getTransaction().commit();
em.close();
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: