Java Code Examples for net.sf.jsqlparser.statement.update.Update#getTables()
The following examples show how to use
net.sf.jsqlparser.statement.update.Update#getTables() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TablesNamesFinder.java From evosql with Apache License 2.0 | 6 votes |
@Override public void visit(Update update) { for (Table table : update.getTables()) { tables.add(table.getName()); } if (update.getExpressions() != null) { for (Expression expression : update.getExpressions()) { expression.accept(this); } } if (update.getFromItem() != null) { update.getFromItem().accept(this); } if (update.getJoins() != null) { for (Join join : update.getJoins()) { join.getRightItem().accept(this); } } if (update.getWhere() != null) { update.getWhere().accept(this); } }
Example 2
Source File: CRUDParseUtils.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public static void parseUpdate(String sql, Table table, Entry entry, Condition condition) throws JSQLParserException, FrontException { Statement statement = CCJSqlParserUtil.parse(sql); Update update = (Update) statement; // parse table name List<net.sf.jsqlparser.schema.Table> tables = update.getTables(); String tableName = tables.get(0).getName(); table.setTableName(tableName); // parse cloumns List<Column> columns = update.getColumns(); List<Expression> expressions = update.getExpressions(); int size = expressions.size(); String[] values = new String[size]; for (int i = 0; i < size; i++) { values[i] = expressions.get(i).toString(); } for (int i = 0; i < columns.size(); i++) { entry.put(trimQuotes(columns.get(i).toString()), trimQuotes(values[i])); } // parse where clause Expression where = update.getWhere(); if (where != null) { BinaryExpression expr2 = (BinaryExpression) (where); handleExpression(condition, expr2); } Limit limit = update.getLimit(); parseLimit(condition, limit); }
Example 3
Source File: TxcSqlExecuteInterceptor.java From tx-lcn with Apache License 2.0 | 5 votes |
@Override public void preUpdate(Update update) throws SQLException { // 获取线程传递参数 Connection connection = (Connection) DTXLocalContext.cur().getResource(); // Update相关数据准备 List<String> columns = new ArrayList<>(update.getColumns().size()); List<String> primaryKeys = new ArrayList<>(3); List<String> tables = new ArrayList<>(update.getTables().size()); update.getColumns().forEach(column -> { column.setTable(update.getTables().get(0)); columns.add(column.getFullyQualifiedName()); }); for (Table table : update.getTables()) { tables.add(table.getName()); TableStruct tableStruct = globalContext.tableStruct(table.getName(), () -> tableStructAnalyser.analyse(connection, table.getName())); tableStruct.getPrimaryKeys().forEach(key -> primaryKeys.add(table.getName() + "." + key)); } // 前置准备 try { UpdateImageParams updateImageParams = new UpdateImageParams(); updateImageParams.setColumns(columns); updateImageParams.setPrimaryKeys(primaryKeys); updateImageParams.setTables(tables); updateImageParams.setWhereSql(update.getWhere() == null ? "1=1" : update.getWhere().toString()); txcService.resolveUpdateImage(updateImageParams); } catch (TxcLogicException e) { throw new SQLException(e.getMessage()); } }
Example 4
Source File: TableRenameVisitor.java From compass with Apache License 2.0 | 5 votes |
@Override public void visit(Update update) { for (Table table : update.getTables()) { table.accept(this); } if (update.getExpressions() != null) { for (Expression expression : update.getExpressions()) { expression.accept(this); } } if (update.getFromItem() != null) { update.getFromItem().accept(this); } if (update.getJoins() != null) { for (Join join : update.getJoins()) { join.getRightItem().accept(this); } } if (update.getWhere() != null) { update.getWhere().accept(this); } }