Hibernate搜索可以与eclipse JPA提供程序一起使用吗?
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
在使用eclipselink JPA进行Hibernate搜索时出现此异常。
FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(ClientEntityManagerHelper.getEntityManager());
// 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 = fullTextEntityManager.getSearchFactory()
.buildQueryBuilder().forEntity(WikiPage.class).get();
org.apache.lucene.search.Query luceneQuery = qb
.keyword()
//.onFields("name", "content", "authors.name")
.onFields("name", "content", "pageSummary")
.matching("wiki")
.createQuery();
例外内容:
线程中的异常&#34; main&#34; org.hibernate.search.SearchException:尝试在没有Hibernate EntityManager的情况下使用Hibernate Search:class org.eclipse.persistence.internal.jpa.EntityManagerImpl
答案 0 :(得分:1)
Hibernate Search强制您将Hibernate用作JPA2实现。您不能将EclipseLink与Hibernate Search一起使用。
有一个项目可以让EclipseLink和其他JPA2实现在这里使用Hibernate Search:
https://github.com/s4ke/hibernate-search/tree/genericjpa/genericjpa