});
} });
    private void emitDDL() {        final HashMap tables = new HashMap();        for (Iterator it = m_root.getTables().iterator(); it.hasNext(); ) {            Table table = (Table) it.next();            tables.put(table.getName(), table);        }        m_ast.traverse(new Node.Switch() {            public void onColumn(ColumnNd colNd) {                    Table table =                        (Table) tables.get(colNd.getTable().getName());                    if (table == null) {                        table = new Table(colNd.getTable().getName());                        tables.put(table.getName(), table);                        m_symbols.setLocation(table, colNd);                    }                    DbTypeNd type = colNd.getType();                    Column col = table.getColumn(colNd.getName().getName());                    if (col == null) {                        col = new Column(colNd.getName().getName());                        table.addColumn(col);                        m_symbols.setLocation(col, colNd);                    }                    if (type != null) {                        col.setType(type.getType());                        col.setSize(type.getSize());                        col.setScale(type.getScale());                    }                }            });        for (Iterator it = tables.values().iterator(); it.hasNext(); ) {            Table table = (Table) it.next();            if (table.getRoot() == null) {                m_root.addTable(table);            }        }        m_ast.traverse(new Node.Switch() {            public void onObjectKey(ObjectKeyNd nd) {                Node parent = nd.getParent();                if (parent instanceof ObjectTypeNd) {                    unique(nd, nd.getProperties(), true);                } else if (parent instanceof NestedMapNd) {                    NestedKeyTraversal nkt = new NestedKeyTraversal();                    nd.traverse(nkt);                    unique(nd, nkt.getColumns(), true);                }            }            public void onUniqueKey(UniqueKeyNd nd) {                unique(nd, nd.getProperties(), false);            }            public void onReferenceKey(ReferenceKeyNd nd) {                unique(nd, new Column[] { lookup(nd.getCol()) }, true);            }            public void onProperty(PropertyNd nd) {                if (nd.isUnique()) {                    ArrayList ids = new ArrayList();                    ids.add(nd.getName());                    unique(nd, ids, false);                }            }        });	m_ast.traverse(new Node.Switch() {		public void onJoinPath(JoinPathNd jpn) {		    List joins = jpn.getJoins();		    if (joins.size() != 2) {			return;		    }		    ColumnNd from = ((JoinNd) joins.get(0)).getTo();		    ColumnNd to = ((JoinNd) joins.get(1)).getFrom();                    boolean collection = true;                    Object obj = getEmitted(jpn.getParent());                    if (obj != null && obj instanceof Property) {                        Property prop = (Property) obj;                        if (!prop.isCollection()) {                            collection = false;                        }                    }                    if (collection) {                        unique(jpn, new Column[] { lookup(from), lookup(to) },                               true);                    } else {                        unique(jpn, new Column[] { lookup(from) }, true);                    }		}	    }, new Node.IncludeFilter(new Node.Field[] {		AST.FILES, FileNd.OBJECT_TYPES, ObjectTypeNd.PROPERTIES,		FileNd.ASSOCIATIONS, AssociationNd.PROPERTIES,		AssociationNd.ROLE_ONE, PropertyNd.MAPPING	    }));        m_ast.traverse(new Node.Switch() {            public void onJoinPath(JoinPathNd jpn) {                List joins = jpn.getJoins();                if (joins.size() != 1) {                    m_errors.fatal                        (jpn, "only length 1 join paths allowed here");                    return;                }                JoinNd join = (JoinNd) joins.get(0);                ColumnNd fromNd = join.getFrom();                ColumnNd toNd = join.getTo();                Column from = lookup(fromNd);                Column to = lookup(toNd);                if (from.isUniqueKey()) {                    unique(toNd, new Column[] { to }, true);                    fk(join, false);                } else if (to.isUniqueKey()) {                    unique(fromNd, new Column[] { from }, true);                    fk(join, true);                } else {                    m_errors.fatal                        (jpn, "join path does not connect to a primary key");                    return;                }            }        }, new Node.IncludeFilter(new Node.Field[] {            AST.FILES, FileNd.OBJECT_TYPES, ObjectTypeNd.JOIN_PATHS        }));    }