That method takes Criterion varargs so to add multiple you just pass in a bunch of Restrictions comma delimited (is that the first part of the question?).
The second part it looks like you want to set order, maxresults etc. You could add a new method to your AbstractHibernateDAO:
Code:
protected List<T> findByCriteria(DetachedCriteria criteria) {
return criteria.getExecutableCriteria(getSession()).list();
}
then your other method would look something like this
Code:
public List<StgAuditGeneral> findBySubAgencyCode(Long subAgencyCode) {
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(StgAuditGeneral.class);
detachedCriteria.add(Restrictions.eq("subAgencyCode", subAgencyCode));
//add more restrictions here if you need.
detachedCriteria.addOrder(Order.asc("subAgencyCode"))
return findByCriteria(detachedCriteria);
}
The problem with this is that maxResults can't be set on a DetachedCriteria object but rather a Criteria object (which you have once you call criteria.getExecutableCriteria(getSession())). So you could pass the max results into the method (dirty) or just use a criteria object and not worry too much about using your method in AbstractHibernateDAO.