public static boolean visit(MappingVisitor visitor, SQLSelectQueryBlock x) { if (x.getSelectList().size() == 0) { fillSelectList(visitor, x); } if (x.getSelectList().size() == 1) { if (x.getSelectList().get(0).getExpr() instanceof SQLAllColumnExpr) { x.getSelectList().clear(); fillSelectList(visitor, x); } } if (x.getFrom() == null) { Entity firstEntity = visitor.getFirstEntity(); SQLExprTableSource from = new SQLExprTableSource(new SQLIdentifierExpr(firstEntity.getName())); x.setFrom(from); } for (SQLSelectItem item : x.getSelectList()) { item.setParent(x); } return true; }
public static void setDataSource(MappingEngine engine, SQLInsertStatement stmt) { if (stmt.getTableSource() == null) { Entity entity = engine.getFirstEntity(); stmt.setTableSource(new SQLIdentifierExpr(entity.getName())); } }