{
logger.debug("createQueryDataSet(tables={}, connection={})", tables, connection);
List queryDataSets = new ArrayList();
QueryDataSet queryDataSet = new QueryDataSet(connection);
for (Iterator it = tables.iterator(); it.hasNext();)
{
Object item = it.next();
if(item instanceof QuerySet) {
if(queryDataSet.getTableNames().length > 0)
queryDataSets.add(queryDataSet);
QueryDataSet newQueryDataSet = (((QuerySet)item).getQueryDataSet(connection));
queryDataSets.add(newQueryDataSet);
queryDataSet = new QueryDataSet(connection);
}
else if (item instanceof Query)
{
Query queryItem = (Query)item;
queryDataSet.addTable(queryItem.getName(), queryItem.getSql());