public <T> List<T> searchObject(Class<T> object, String objectName, String[] caminhos, String[] colunas, String[] propertyNames, Object[] valores) throws Exception {
    List<T> listObjectReturn;
    Session sessao = HibernateUtil.getSession();
    Criteria consultar = sessao.createCriteria(object, objectName);

    if (caminhos != null) {
      for (int x = 0; x < caminhos.length; x++) {
        consultar.createAlias(caminhos[x], colunas[x]);
      }
    }

    for (int x = 0; x < propertyNames.length; x++) {
      if (valores[x] != null) {
        if (valores[x] instanceof String) {
          if (!(valores[x].equals(""))) {
            consultar.add(Restrictions.like(propertyNames[x], "%" + valores[x] + "%"));
          }
        } else {
          consultar.add(Restrictions.like(propertyNames[x], valores[x]));
        }
      }
    }
    listObjectReturn = consultar.list();
    sessao.close();
    return listObjectReturn;
  }