Class CriteriaSearch


  • public class CriteriaSearch
    extends Object
    Implements a generic search mechanism based on the Hibernate Criteria API. The CriteriaSearch allows adding parameters which function as where clause. The parameters are analysed whether they should be considered or not. This depends both on the actual value of the parameter and on the configuration.
    The CriteriaSearch is expected to be a general solution for a basic search with parameters connected by logical and. This search does not provide grouping.
    See Also:
    Criteria, Expression
    • Constructor Detail

      • CriteriaSearch

        public CriteriaSearch​(org.hibernate.Session session,
                              Class resultType)
        Constructor for CriteriaSearch. Creates a CriteriaSearch with a default CriteriaSearchConfiguration.
        Parameters:
        session - The Hibernate session.
        resultType - The Class of the result.
    • Method Detail

      • executeAsSet

        public final Set executeAsSet()
                               throws org.hibernate.HibernateException
        Executes a HibernateQuery using the currently defined CriteriaSearchParameters, and returns a java.util.Set containing the query results.
        Returns:
        result The result of the query.
        Throws:
        org.hibernate.HibernateException
      • executeAsList

        public List executeAsList()
                           throws org.hibernate.HibernateException
        Executes a HibernateQuery using the currently defined CriteriaSearchParameters, and returns a java.util.List containing the query results.
        Returns:
        result The result of the query.
        Throws:
        org.hibernate.HibernateException
      • addParameter

        public void addParameter​(Object parameterValue,
                                 String parameterPattern)
                          throws org.hibernate.HibernateException
        Adds a CriteriaSearchParameter to this search. The parameter is connected to the search by logical and. It is not considered if the value is null. If the value is not null it is compared using the CriteriaSearchParameter.EQUALS_COMPARATOR.
        Parameters:
        parameterValue - The value of the parameter.
        parameterPattern - The pattern of the parameter (dot-seperated path e.g. person.address.street).
        Throws:
        org.hibernate.HibernateException
      • addParameter

        public void addParameter​(String parameterValue,
                                 String parameterPattern)
                          throws org.hibernate.HibernateException
        Adds a CriteriaSearchParameter to this search. The parameter is connected to the search by logical and. It is not considered if the value is null or if the String empty. If the value is not null it is compared using the CriteriaSearchParameter.LIKE_COMPARATOR.
        Parameters:
        parameterValue - The value of the parameter.
        parameterPattern - The pattern of the parameter (dot-seperated path e.g. person.address.street).
        Throws:
        org.hibernate.HibernateException
      • addParameter

        public void addParameter​(CriteriaSearchParameter parameter)
                          throws org.hibernate.HibernateException
        Adds a CriteriaSearchParameter to this search. The parameter is connected to the search by logical and.
        Parameters:
        parameter - The CriteriaSearchParameter to add.
        Throws:
        org.hibernate.HibernateException
      • getConfiguration

        public CriteriaSearchConfiguration getConfiguration()
        Returns the configuration of this search.
        Returns:
        configuration