当前位置: 首页>>代码示例>>Java>>正文


Java Update.getWhere方法代码示例

本文整理汇总了Java中net.sf.jsqlparser.statement.update.Update.getWhere方法的典型用法代码示例。如果您正苦于以下问题:Java Update.getWhere方法的具体用法?Java Update.getWhere怎么用?Java Update.getWhere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.jsqlparser.statement.update.Update的用法示例。


在下文中一共展示了Update.getWhere方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:26,代码来源:TablesNamesFinder.java

示例2: visit

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
@Override
public void visit(Update update) {
    for (Table table : update.getTables()) {
        tables.add(table, table1 -> 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);
    }
}
 
开发者ID:justice-code,项目名称:QiuQiu,代码行数:26,代码来源:ReplaceTablesNamesFinder.java

示例3: visit

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
@Override
public void visit(Update update) {
    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);
    }
}
 
开发者ID:hellojavaer,项目名称:ddal,代码行数:23,代码来源:JSQLBaseVisitor.java

示例4: parse

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
public Set<String> parse(Update update) {
	
	Set<String> tableSet = new HashSet<String>();
	
	if (update != null) {
		List<Table> tables = update.getTables();
		for (Table table : tables) {
			tableSet.add(table.getName());
		}
		Expression expression = update.getWhere();
		if (expression != null) {
			tableSet.addAll(parseExpression(expression));
		}
	}
	return tableSet;
}
 
开发者ID:PinaeOS,项目名称:timon,代码行数:17,代码来源:UpdateParser.java

示例5: createInsertSelectOnDuplicateKeyUpdateStatement

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
/**
 * Transform the given UPDATE-statement into an "INSERT INTO TAB1 (...)
 * SELECT ... FROM TAB1 WHERE ... ON DUPLICATE KEY UPDATE"
 * 
 * @param update
 *            The UPDATE-statement
 * @return An SQL-statement equal to the UPDATE-statement but in INSERT form
 * @throws SQLException
 *             if a database exception occurs while getting the table meta
 *             data or if the statement tries to update the primary key
 *             value
 */
protected String createInsertSelectOnDuplicateKeyUpdateStatement(Update update) throws SQLException
{
	String tableName = unquoteIdentifier(update.getTables().get(0).getName());
	TableKeyMetaData table = getConnection().getTable(tableName);
	List<String> keyColumns = table.getKeyColumns();
	List<String> updateColumns = update.getColumns().stream().map(x -> x.getColumnName())
			.collect(Collectors.toList());
	List<String> quotedKeyColumns = keyColumns.stream().map(x -> quoteIdentifier(x)).collect(Collectors.toList());
	List<String> quotedAndQualifiedKeyColumns = keyColumns.stream()
			.map(x -> quoteIdentifier(tableName) + "." + quoteIdentifier(x)).collect(Collectors.toList());

	List<String> quotedUpdateColumns = updateColumns.stream().map(x -> quoteIdentifier(x))
			.collect(Collectors.toList());
	List<String> expressions = update.getExpressions().stream().map(x -> x.toString()).collect(Collectors.toList());
	if (updateColumns.stream().anyMatch(x -> keyColumns.contains(x)))
	{
		String invalidCols = updateColumns.stream().filter(x -> keyColumns.contains(x))
				.collect(Collectors.joining());
		throw new CloudSpannerSQLException(
				"UPDATE of a primary key value is not allowed, cannot UPDATE the column(s) " + invalidCols,
				Code.INVALID_ARGUMENT);
	}

	StringBuilder res = new StringBuilder();
	res.append("INSERT INTO ").append(quoteIdentifier(tableName)).append("\n(");
	res.append(String.join(", ", quotedKeyColumns)).append(", ");
	res.append(String.join(", ", quotedUpdateColumns)).append(")");
	res.append("\nSELECT ").append(String.join(", ", quotedAndQualifiedKeyColumns)).append(", ");
	res.append(String.join(", ", expressions));
	res.append("\nFROM ").append(quoteIdentifier(tableName));
	if (update.getWhere() != null)
		res.append("\n").append("WHERE ").append(update.getWhere().toString());
	res.append("\nON DUPLICATE KEY UPDATE");

	return res.toString();
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:49,代码来源:AbstractCloudSpannerStatement.java

示例6: visit

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
@Override
public void visit(Update s) {
    for (Table table : s.getTables()) {
        visit(table);
    }
    if (s.getColumns() != null) {
        s.getColumns().forEach(c -> {
            c.accept(this);
        });
    }
    if (s.getExpressions() != null) {
        s.getExpressions().forEach(e -> e.accept(this));
    }
    if (s.getOrderByElements() != null) {
        s.getOrderByElements().forEach(o -> {
            o.accept(this);
        });
    }
    if (s.getWhere() != null) {
        s.getWhere().accept(this);
    }
    if (s.getReturningExpressionList() != null) {
        s.getReturningExpressionList().forEach(o -> {
            o.accept(this);
        });

    }
}
 
开发者ID:diennea,项目名称:herddb,代码行数:29,代码来源:JdbcQueryRewriter.java

示例7: visit

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:sogou-biztech,项目名称:compass,代码行数:34,代码来源:TableRenameVisitor.java

示例8: deParse

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
public void deParse(Update aUpdate) {
    buffer.append(aUpdate.getComment() != null ? aUpdate.getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("Update ").append(ExpressionDeParser.LINE_SEPARATOR)
            .append(aUpdate.getTable().getComment() != null ? aUpdate.getTable().getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(aUpdate.getTable().getWholeTableName()).append(ExpressionDeParser.LINE_SEPARATOR)
            .append(aUpdate.getCommentSet() != null ? " " + aUpdate.getCommentSet() + ExpressionDeParser.LINE_SEPARATOR : "").append(" set ");
    int columnsCounter = 0;
    for (int i = 0, s = aUpdate.getColumns().size(); i < s; i++) {
        Column column = (Column) aUpdate.getColumns().get(i);
        buffer.append(column.getComment() != null ? column.getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(column.getWholeColumnName())
                .append(!aUpdate.getCommentsEqaulas().get(i).toString().isEmpty() ? " " + aUpdate.getCommentsEqaulas().get(i) + ExpressionDeParser.LINE_SEPARATOR : "").append(" = ");
        Expression expression = (Expression) aUpdate.getExpressions().get(i);
        expression.accept(expressionVisitor);
        if (i < aUpdate.getColumns().size() - 1) {
            buffer.append(!aUpdate.getCommentsComma().get(i).toString().isEmpty() ? " " + aUpdate.getCommentsComma().get(i) + " " : "");
            if (columnsCounter++ == 2) {
                columnsCounter = 0;
                buffer.append(ExpressionDeParser.LINE_SEPARATOR).append(", ");
            } else {
                buffer.append(", ");
            }
        }
    }

    if (aUpdate.getWhere() != null) {
        buffer.append(aUpdate.getCommentWhere() != null ? " " + aUpdate.getCommentWhere() : "")
                .append(ExpressionDeParser.LINE_SEPARATOR).append(" Where ");
        aUpdate.getWhere().accept(expressionVisitor);
    }
    buffer.append(!"".equals(aUpdate.getEndComment()) ? " " + aUpdate.getEndComment() : "");
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:30,代码来源:UpdateDeParser.java

示例9: buildUpdateStatement

import net.sf.jsqlparser.statement.update.Update; //导入方法依赖的package包/类
private ExecutionPlan buildUpdateStatement(String defaultTableSpace, Update s,
    boolean returnValues) throws StatementExecutionException {
    if (s.getTables().size() != 1) {
        throw new StatementExecutionException("unsupported multi-table update " + s);
    }
    net.sf.jsqlparser.schema.Table fromTable = s.getTables().get(0);
    String tableSpace = fromTable.getSchemaName();
    String tableName = fromTable.getName();
    if (tableSpace == null) {
        tableSpace = defaultTableSpace;
    }
    TableSpaceManager tableSpaceManager = manager.getTableSpaceManager(tableSpace);
    if (tableSpaceManager == null) {
        throw new StatementExecutionException("no such tablespace " + tableSpace + " here at " + manager.getNodeId());
    }
    AbstractTableManager tableManager = tableSpaceManager.getTableManager(tableName);
    if (tableManager == null) {
        throw new StatementExecutionException("no such table " + tableName + " in tablespace " + tableSpace);
    }
    Table table = tableManager.getTable();
    for (net.sf.jsqlparser.schema.Column c : s.getColumns()) {
        Column column = table.getColumn(c.getColumnName());
        if (column == null) {
            throw new StatementExecutionException("no such column " + c.getColumnName() + " in table " + tableName + " in tablespace " + tableSpace);
        }
        if (table.isPrimaryKeyColumn(c.getColumnName())) {
            throw new StatementExecutionException("updates of fields on the PK (" + Arrays.toString(table.primaryKey) + ") are not supported. Please perform a DELETE and than an INSERT");
        }
    }

    List<CompiledSQLExpression> compiledSQLExpressions = new ArrayList<>();
    for (Expression e : s.getExpressions()) {
        compiledSQLExpressions.add(SQLExpressionCompiler.compileExpression(null, e));
    }
    RecordFunction function = new SQLRecordFunction(table, s.getColumns(), compiledSQLExpressions);

    // Perform a scan and then update each row
    SQLRecordPredicate where = s.getWhere() != null ? new SQLRecordPredicate(table, table.name, s.getWhere()) : null;
    if (where != null) {
        Expression expressionWhere = s.getWhere();
        discoverIndexOperations(expressionWhere, table, table.name, where, tableSpaceManager);
    }
    DMLStatement st = new UpdateStatement(tableSpace, tableName, null, function, where)
        .setReturnValues(returnValues);
    return ExecutionPlan.simple(st);

}
 
开发者ID:diennea,项目名称:herddb,代码行数:48,代码来源:SQLPlanner.java


注:本文中的net.sf.jsqlparser.statement.update.Update.getWhere方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。