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


Java Update类代码示例

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


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

示例1: createUpdateMutation

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
private Mutation createUpdateMutation(Update update, boolean generateParameterMetaData) throws SQLException
{
	if (update.getTables().isEmpty())
		throw new CloudSpannerSQLException("No table found in update statement", Code.INVALID_ARGUMENT);
	if (update.getTables().size() > 1)
		throw new CloudSpannerSQLException("Update statements for multiple tables at once are not supported",
				Code.INVALID_ARGUMENT);
	String table = unquoteIdentifier(update.getTables().get(0).getFullyQualifiedName());
	getParameterStore().setTable(table);
	List<Expression> expressions = update.getExpressions();
	WriteBuilder builder = Mutation.newUpdateBuilder(table);
	int index = 0;
	for (Column col : update.getColumns())
	{
		String columnName = unquoteIdentifier(col.getFullyQualifiedName());
		expressions.get(index).accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
				builder.set(columnName), columnName));
		index++;
	}
	visitUpdateWhereClause(update.getWhere(), builder, generateParameterMetaData);

	return builder.build();
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:24,代码来源:CloudSpannerPreparedStatement.java

示例2: createInsertWithSelectStatement

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
private InsertWorker createInsertWithSelectStatement(Insert insert, boolean forceUpdate) throws SQLException
{
	Select select = insert.getSelect();
	if (select == null)
	{
		throw new CloudSpannerSQLException("Insert statement must contain a select statement",
				Code.INVALID_ARGUMENT);
	}
	boolean isDuplicate = insert.isUseDuplicate();
	InsertWorker.DMLOperation mode;
	if (forceUpdate)
		mode = DMLOperation.Update;
	else if (isDuplicate)
		mode = DMLOperation.OnDuplicateKeyUpdate;
	else
		mode = DMLOperation.Insert;
	return new InsertWorker(getConnection(), select, insert, getConnection().isAllowExtendedMode(), mode);
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:19,代码来源:CloudSpannerPreparedStatement.java

示例3: 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

示例4: 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

示例5: 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

示例6: JSQLParserAdapter

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
public JSQLParserAdapter(String sql, ShardRouter shardRouter, boolean enableLimitCheck) {
    this.sql = sql;
    this.shardRouter = shardRouter;
    this.enableLimitCheck = enableLimitCheck;
    try {
        this.statement = CCJSqlParserUtil.parse(sql);
    } catch (Throwable e) {
        throw new SQLSyntaxErrorException("sql is [" + sql + "]", e);
    }
    if (statement instanceof Select //
        || statement instanceof Update//
        || statement instanceof Insert//
        || statement instanceof Delete) {
        // ok
    } else {
        throw new UnsupportedSQLExpressionException(
                                                    "Sql ["
                                                            + sql
                                                            + "] is not supported in shard sql. Only support 'select' 'insert' 'update' and 'delete' sql statement");
    }
}
 
开发者ID:hellojavaer,项目名称:ddal,代码行数:22,代码来源:JSQLParserAdapter.java

示例7: visit

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
@Override
public void visit(Update update) {
    if (enableLimitCheck && update.getLimit() == null) {
        throw new IllegalStateException("no limit in sql: " + sql);
    }
    this.getStack().push(new FrameContext());
    if (update.getTables() != null) {
        for (Table table : update.getTables()) {
            ShardRouteConfig routeConfig = shardRouter.getRouteConfig(table.getSchemaName(), table.getName());
            if (routeConfig != null) {
                TableWrapper tab = new TableWrapper(table, routeConfig);
                addRoutedTableIntoContext(tab, routeConfig, true);
            }
        }
    }
    super.visit(update);
    afterVisitBaseStatement();
}
 
开发者ID:hellojavaer,项目名称:ddal,代码行数:19,代码来源:JSQLParserAdapter.java

示例8: 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

示例9: 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

示例10: getParameterMetaData

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
@Override
public CloudSpannerParameterMetaData getParameterMetaData() throws SQLException
{
	// parse the SQL statement without executing it
	try
	{
		if (isDDLStatement())
		{
			throw new CloudSpannerSQLException("Cannot get parameter meta data for DDL statement",
					Code.INVALID_ARGUMENT);
		}
		Statement statement = CCJSqlParserUtil.parse(sanitizeSQL(sql));
		if (statement instanceof Insert || statement instanceof Update || statement instanceof Delete)
		{
			// Create mutation, but don't do anything with it. This
			// initializes column names of the parameter store.
			createMutations(sql, false, true);
		}
		else if (statement instanceof Select)
		{
			// Create select builder, but don't do anything with it. This
			// initializes column names of the parameter store.
			createSelectBuilder(statement, sql);
		}
	}
	catch (JSQLParserException | TokenMgrError e)
	{
		throw new CloudSpannerSQLException(PARSE_ERROR + sql + ": " + e.getLocalizedMessage(),
				Code.INVALID_ARGUMENT, e);
	}
	return new CloudSpannerParameterMetaData(this);
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:33,代码来源:CloudSpannerPreparedStatement.java

示例11: visit

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
@Override
public void visit(Update update) {
    SelectDeParser selectDeParser = new SelectDeParser();
    selectDeParser.setBuffer(buffer);
    ExpressionDeParser expressionDeParser = new ExpressionDeParser(selectDeParser, buffer);
    UpdateDeParser updateDeParser = new UpdateDeParser(expressionDeParser, selectDeParser, buffer);
    selectDeParser.setExpressionVisitor(expressionDeParser);
    updateDeParser.deParse(update);

}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:11,代码来源:StatementDeParser.java

示例12: updateCase

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
private void updateCase(Update update){
    List<Column> columns = update.getColumns();
    System.out.println(columns);
    List<Expression> expressions = update.getExpressions();
    int index = 0;
    for (Expression exp:expressions){
        handleColumn(columns.get(index),exp,paramNames);
        index++;
    }
    handleWhereCause(update.getWhere(), paramNames);
}
 
开发者ID:rpgmakervx,项目名称:slardar,代码行数:12,代码来源:JSqlParser.java

示例13: processConvert

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
@Override
protected Statement processConvert(Statement statement,String tableName, Object param, String expression) {
    Update update = (Update) statement;
    
    Table table = update.getTables().get(0);
    
    String tableOrginName = table.getName();
    
    String index = calcFunctionExpressionResult(expression, param);
    
    String suffix = getSuffixedIndex(index);
    table.setName(super.concatTableName(tableOrginName, suffix));
    return update;
}
 
开发者ID:devpage,项目名称:sharding-quickstart,代码行数:15,代码来源:UpdateSingleTableRoute.java

示例14: plan

import net.sf.jsqlparser.statement.update.Update; //导入依赖的package包/类
@Override
public ExecutionPlan plan(String defaultTableSpace, net.sf.jsqlparser.statement.Statement stmt,
    boolean scan, boolean returnValues, int maxRows) {
    verifyJdbcParametersIndexes(stmt);
    ExecutionPlan result;
    if (stmt instanceof CreateTable) {
        result = ExecutionPlan.simple(buildCreateTableStatement(defaultTableSpace, (CreateTable) stmt));
    } else if (stmt instanceof CreateIndex) {
        result = ExecutionPlan.simple(buildCreateIndexStatement(defaultTableSpace, (CreateIndex) stmt));
    } else if (stmt instanceof Insert) {
        result = buildInsertStatement(defaultTableSpace, (Insert) stmt, returnValues);
    } else if (stmt instanceof Delete) {
        result = buildDeleteStatement(defaultTableSpace, (Delete) stmt, returnValues);
    } else if (stmt instanceof Update) {
        result = buildUpdateStatement(defaultTableSpace, (Update) stmt, returnValues);
    } else if (stmt instanceof Select) {
        result = buildSelectStatement(defaultTableSpace, (Select) stmt, scan, maxRows);
    } else if (stmt instanceof Execute) {
        result = ExecutionPlan.simple(buildExecuteStatement(defaultTableSpace, (Execute) stmt));
    } else if (stmt instanceof Alter) {
        result = ExecutionPlan.simple(buildAlterStatement(defaultTableSpace, (Alter) stmt));
    } else if (stmt instanceof Drop) {
        result = ExecutionPlan.simple(buildDropStatement(defaultTableSpace, (Drop) stmt));
    } else if (stmt instanceof Truncate) {
        result = ExecutionPlan.simple(buildTruncateStatement(defaultTableSpace, (Truncate) stmt));
    } else {
        return null;
    }
    return result;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:31,代码来源:SQLPlanner.java

示例15: 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


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