code: private org.hibernate.Query query(String hql, Class<?>... type)
    {
      org.hibernate.Query q = session.createQuery(hql);
      for(int i = 0; i < positionedParameters.length; i++) {
        q.setParameter(i, positionedParameters[i]);
      }
      for(Map.Entry<String, Object> entry : namedParameters.entrySet()) {
        Object value = entry.getValue();
        if(Types.isArray(value)) {
          Object[] parameter = (Object[])value;
          if(parameter.length == 0) {
            throw new HibernateException(String.format("Invalid named parameter |%s|. Empty array.", entry.getKey()));
          }
          q.setParameterList(entry.getKey(), parameter);
        }
        else if(Types.isCollection(value)) {
          Collection<?> parameter = (Collection<?>)value;
          if(parameter.isEmpty()) {
            throw new HibernateException(String.format("Invalid named parameter |%s|. Empty list.", entry.getKey()));
          }
          q.setParameterList(entry.getKey(), parameter);
        }
        else {
          q.setParameter(entry.getKey(), value);
        }
      }
      if(offset > 0) {
        q.setFirstResult(offset);
      }
      if(rowsCount > 0) {
        q.setMaxResults(rowsCount);
      }
  
      if(type.length > 0) {
        q.setResultTransformer(Transformers.aliasToBean(type[0]));
      }
      return q;
    }
docs: Create Hibernate query object and initialize it from this helper properties.
  
  @param hql query string expressed in HQL.
  @return newly created Hibernate query object.