public <T> QueryResult<T> findAllBySearch(Class<T> voClass,
			List<Class<?>> entitysClass, int firstIndex, int maxResult,
			Map<String, String> OrderBy, String sql_where,
			List<Object> parames, int flag) throws DBException {
		// 拿到vo实体类在xml映射文件中的实体节点
		Element voElement = null;

		if (false == CheckEntityUtil.doCheck(voClass)) {
			throw new DBException("所操作的类在xml中不存在！请检查！");
		}

		voElement = ReadXmlUtil.getElement(voClass);
		// 得到组成vo的Po实体的节点的集合,和对应物理表的名字;
		List<Element> entitysElement = new ArrayList<Element>();
		List<String> tableNames = new ArrayList<String>();
		for (Class<?> entity : entitysClass) {
			if (false == CheckEntityUtil.doCheck(entity)) {
				throw new DBException("所操作的类在xml中不存在！请检查！");
			}
			Element element = ReadXmlUtil.getElement(entity);

			entitysElement.add(element);

			String tableName = element.attributeValue("table");

			tableNames.add(tableName);

		}
		if (null == sql_where || "".equals(sql_where)) {
			// 通过得到的Vo实体的节点,涉及的几张表,查询条件;来进行拼接Sql语句
			String searchSql = parseSqlUtil.createSearchSqlByAdvance(voElement,
					tableNames, sql_where);
			searchSql = searchSql + " limit " + firstIndex + "," + maxResult;
			System.out.println(searchSql);
			List<T> list = daoOptemplate.getInstance().query(searchSql,
					voElement, voClass);
			int listSize = list.size();
			QueryResult<T> result = new QueryResult<T>();
			result.setResults(list);
			result.setCountRecords(listSize);
			return result;
		} else {
			// 通过得到的Vo实体的节点,涉及的几张表,查询条件;来进行拼接Sql语句
			String searchSql = parseSqlUtil.createSearchSqlByAdvance(voElement,
					tableNames, sql_where);
			searchSql = searchSql + " limit " + firstIndex + "," + maxResult;
			System.out.println(searchSql);
			// 得到查询条件对应的数据类型,通过和Vo的字段数据进行匹配
			List<String> listTypes = parseSqlUtil.getListTypeToSearchByAdvance(
					voElement, sql_where);

			// 调用模板类的查询方法
			List<T> list = daoOptemplate.getInstance().query(searchSql,
					parames, listTypes, voElement, voClass);
			int listSize = list.size();
			QueryResult<T> result = new QueryResult<T>();
			result.setResults(list);
			result.setCountRecords(listSize);

			return result;
		}

	}