public class CriteriaSearch extends Object
CriteriaSearch
allows adding parameters which function as where clause. The
parameters are analyzed whether they should be considered or not. This depends both on the actual
value of the parameter and on the configuration.CriteriaSearch
is expected to be a general solution for a basic search with
parameters connected by logical and. This search does not provide grouping.Criteria
,
Restrictions
Constructor and Description |
---|
CriteriaSearch(Session session,
Class resultTypeIn)
Constructor for CriteriaSearch.
|
Modifier and Type | Method and Description |
---|---|
void |
addParameter(CriteriaSearchParameter parameter)
Adds a
CriteriaSearchParameter to this search. |
void |
addParameter(Object parameterValue,
String parameterPattern)
Adds a
CriteriaSearchParameter to this search. |
void |
addParameter(String parameterValue,
String parameterPattern)
Adds a
CriteriaSearchParameter to this search. |
List |
executeAsList()
Executes a
HibernateQuery using the currently defined
CriteriaSearchParameter s, and returns a java.util.List
containing the query results. |
Set |
executeAsSet()
Executes a
HibernateQuery using the currently defined
CriteriaSearchParameter s, and returns a java.util.Set
containing the query results. |
CriteriaSearchConfiguration |
getConfiguration()
Returns the configuration of this search.
|
protected Criteria |
getRootCriteria()
Exposes the root criteria to subclasses.
|
public CriteriaSearch(Session session, Class resultTypeIn)
CriteriaSearch
with a default
CriteriaSearchConfiguration
.session
- The Hibernate session.resultTypeIn
- The Class
of the result.protected Criteria getRootCriteria()
public Set executeAsSet() throws HibernateException
HibernateQuery
using the currently defined
CriteriaSearchParameter
s, and returns a java.util.Set
containing the query results.HibernateException
public List executeAsList() throws HibernateException
HibernateQuery
using the currently defined
CriteriaSearchParameter
s, and returns a java.util.List
containing the query results.HibernateException
public void addParameter(Object parameterValue, String parameterPattern) throws HibernateException
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
.parameterValue
- The value of the parameter.parameterPattern
- The pattern of the parameter (dot-separated path e.g. person.address.street).HibernateException
public void addParameter(String parameterValue, String parameterPattern) throws HibernateException
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
.parameterValue
- The value of the parameter.parameterPattern
- The pattern of the parameter (dot-separated path e.g. person.address.street).HibernateException
public void addParameter(CriteriaSearchParameter parameter) throws HibernateException
CriteriaSearchParameter
to this search. The parameter is connected to
the search by logical and.parameter
- The CriteriaSearchParameter
to add.HibernateException
public CriteriaSearchConfiguration getConfiguration()
Copyright © 2012–2014 IFREMER. All rights reserved.