Class Search
- java.lang.Object
-
- org.hibernate.search.mapper.orm.Search
-
public final class Search extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SearchMappingmapping(javax.persistence.EntityManagerFactory entityManagerFactory)Retrieve theSearchMappingfrom a JPAEntityManagerFactory.static SearchMappingmapping(SessionFactory sessionFactory)Retrieve theSearchMappingfrom a Hibernate ORMSessionFactory.static SearchSessionsession(javax.persistence.EntityManager entityManager)Retrieve theSearchSessionfrom a JPAEntityManager.static SearchSessionsession(Session session)Retrieve theSearchSessionfrom a Hibernate ORMSession.static <H> javax.persistence.TypedQuery<H>toJpaQuery(SearchQuery<H> searchQuery)Convert aSearchQueryto aJPA query.static <H> Query<H>toOrmQuery(SearchQuery<H> searchQuery)Convert aSearchQueryto aHibernate ORM query.
-
-
-
Method Detail
-
mapping
public static SearchMapping mapping(SessionFactory sessionFactory)
Retrieve theSearchMappingfrom a Hibernate ORMSessionFactory.- Parameters:
sessionFactory- A Hibernate ORM session factory.- Returns:
- The corresponding
SearchSession. - Throws:
SearchException- if the session NOTSharedSessionContract.isOpen().
-
mapping
public static SearchMapping mapping(javax.persistence.EntityManagerFactory entityManagerFactory)
Retrieve theSearchMappingfrom a JPAEntityManagerFactory.- Parameters:
entityManagerFactory- A JPA entity manager factory.- Returns:
- The corresponding
SearchSession. - Throws:
SearchException- if the session NOTSharedSessionContract.isOpen().
-
session
public static SearchSession session(Session session)
Retrieve theSearchSessionfrom a Hibernate ORMSession.The resulting instance depends on the passed
Session: closing theSessionwill close theSearchSession. TheSearchSessionwill share theSession's persistence context.- Parameters:
session- A Hibernate ORM session.- Returns:
- The corresponding
SearchSession. - Throws:
SearchException- if the session NOTSharedSessionContract.isOpen().
-
session
public static SearchSession session(javax.persistence.EntityManager entityManager)
Retrieve theSearchSessionfrom a JPAEntityManager.The resulting instance depends on the passed
EntityManager: closing theEntityManagerwill close theSearchSession. TheSearchSessionwill share theEntityManager's persistence context.- Parameters:
entityManager- A JPA entity manager.- Returns:
- The corresponding
SearchSession. - Throws:
SearchException- if the entity manager NOTEntityManager.isOpen().
-
toJpaQuery
public static <H> javax.persistence.TypedQuery<H> toJpaQuery(SearchQuery<H> searchQuery)
Convert aSearchQueryto aJPA query.Note that the resulting query does not support all operations and may behave slightly differently from what is expected from a
TypedQueryin some cases (including, but not limited to, the type of thrown exceptions). For these reasons, it is recommended to only use this method when absolutely required, for example when integrating to an external library that expects JPA queries.- Type Parameters:
H- The type of query hits.- Parameters:
searchQuery- The search query to convert.- Returns:
- A representation of the given query as a JPA query.
-
toOrmQuery
public static <H> Query<H> toOrmQuery(SearchQuery<H> searchQuery)
Convert aSearchQueryto aHibernate ORM query.Note that the resulting query does not support all operations and may behave slightly differently from what is expected from a
Queryin some cases (including, but not limited to, the type of thrown exceptions). For these reasons, it is recommended to only use this method when absolutely required, for example when integrating to an external library that expects Hibernate ORM queries.- Type Parameters:
H- The type of query hits.- Parameters:
searchQuery- The search query to convert.- Returns:
- A representation of the given query as a Hibernate ORM query.
-
-