Class Search


  • public final class Search
    extends Object
    • Method Detail

      • session

        public static SearchSession session​(javax.persistence.EntityManager entityManager)
        Retrieve the SearchSession from a JPA EntityManager.

        The resulting instance depends on the passed EntityManager: closing the EntityManager will close the SearchSession. The SearchSession will share the EntityManager's persistence context.

        Parameters:
        entityManager - A JPA entity manager.
        Returns:
        The corresponding SearchSession.
        Throws:
        SearchException - if the entity manager NOT EntityManager.isOpen().
      • toJpaQuery

        public static <H> javax.persistence.TypedQuery<H> toJpaQuery​(SearchQuery<H> searchQuery)
        Convert a SearchQuery to a JPA 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

        public static <H> Query<H> toOrmQuery​(SearchQuery<H> searchQuery)
        Convert a SearchQuery to a Hibernate 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.