@Override public boolean visit(SQLInsertStatement x) { setMode(x, Mode.Insert); setAliasMap(); String originalTable = getCurrentTable(); if (x.getTableName() instanceof SQLName) { String ident = ((SQLName) x.getTableName()).toString(); setCurrentTable(ident); x.putAttribute("_old_local_", originalTable); TableStat stat = getTableStat(ident); stat.incrementInsertCount(); Map<String, String> aliasMap = getAliasMap(); if (aliasMap != null) { if (x.getAlias() != null) { aliasMap.put(x.getAlias(), ident); } aliasMap.put(ident, ident); } } accept(x.getColumns()); accept(x.getQuery()); return false; }
public static void setDataSource(MappingEngine engine, SQLInsertStatement stmt) { if (stmt.getTableSource() == null) { Entity entity = engine.getFirstEntity(); stmt.setTableSource(new SQLIdentifierExpr(entity.getName())); } }