[hibernate-issues] [Hibernate-JIRA] Created: (HSEARCH-773) Example in documentation contains compilation erros

Juraj Martinka (JIRA) noreply at atlassian.com
Fri May 20 16:13:24 EDT 2011


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


"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/#d0e384

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.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list