You can add criteria as needed, so just check your parameters for a null value, if they are not equal to zero, then add the criteria. Example:
Criteria cr = session.createCriteria(Employee.class)
cr.add(Restrictions.like("firstName", "Bob%"));
if (par_salary.IsNotNullOrEmpty())
{
cr.add(Restrictions.eq("salary", par_salary));
}
List results = cr.list();
part of this is taken from Hibernation Requests
source
share