Class Search
-
Method Summary
Modifier and TypeMethodDescriptionstatic SearchMapping
mapping
(jakarta.persistence.EntityManagerFactory entityManagerFactory) Retrieve theSearchMapping
from a JPAEntityManagerFactory
.static SearchMapping
mapping
(SessionFactory sessionFactory) Retrieve theSearchMapping
from a Hibernate ORMSessionFactory
.static SearchSession
session
(jakarta.persistence.EntityManager entityManager) Retrieve theSearchSession
from a JPAEntityManager
.static SearchSession
Retrieve theSearchSession
from a Hibernate ORMSession
.static <H> jakarta.persistence.TypedQuery<H>
toJpaQuery
(SearchQuery<H> searchQuery) Convert aSearchQuery
to aJPA query
.static <H> Query<H>
toOrmQuery
(SearchQuery<H> searchQuery) Convert aSearchQuery
to aHibernate ORM query
.
-
Method Details
-
mapping
Retrieve theSearchMapping
from a Hibernate ORMSessionFactory
.- Parameters:
sessionFactory
- A Hibernate ORM session factory.- Returns:
- The corresponding
SearchSession
. - Throws:
SearchException
- if the session NOTSharedSessionContract.isOpen()
.
-
mapping
Retrieve theSearchMapping
from a JPAEntityManagerFactory
.- Parameters:
entityManagerFactory
- A JPA entity manager factory.- Returns:
- The corresponding
SearchSession
. - Throws:
SearchException
- if the session NOTSharedSessionContract.isOpen()
.
-
session
Retrieve theSearchSession
from a Hibernate ORMSession
.The resulting instance depends on the passed
Session
: closing theSession
will close theSearchSession
. TheSearchSession
will share theSession
's persistence context.- Parameters:
session
- A Hibernate ORM session.- Returns:
- The corresponding
SearchSession
. - Throws:
SearchException
- if the session NOTSharedSessionContract.isOpen()
.
-
session
Retrieve theSearchSession
from a JPAEntityManager
.The resulting instance depends on the passed
EntityManager
: closing theEntityManager
will close theSearchSession
. TheSearchSession
will share theEntityManager
's persistence context.- Parameters:
entityManager
- A JPA entity manager.- Returns:
- The corresponding
SearchSession
. - Throws:
SearchException
- if the entity manager NOTEntityManager.isOpen()
.
-
toJpaQuery
Convert aSearchQuery
to aJPA query
.Note that the resulting query does not support all operations and may behave slightly differently from what is expected from a
TypedQuery
in 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
Convert aSearchQuery
to aHibernate ORM query
.Note that the resulting query does not support all operations and may behave slightly differently from what is expected from a
Query
in 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.
-