本文整理了Java中net.sf.jsqlparser.statement.update.Update
类的一些代码示例,展示了Update
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Update
类的具体详情如下:
包路径:net.sf.jsqlparser.statement.update.Update
类名称:Update
[英]The update statement.
[中]更新语句。
代码示例来源:origin: JSQLParser/JSqlParser
public void deParse(Update update) {
buffer.append("UPDATE ").append(PlainSelect.getStringList(update.getTables(), true, false)).
append(" SET ");
if (!update.isUseSelect()) {
for (int i = 0; i < update.getColumns().size(); i++) {
Column column = update.getColumns().get(i);
column.accept(expressionVisitor);
Expression expression = update.getExpressions().get(i);
expression.accept(expressionVisitor);
if (i < update.getColumns().size() - 1) {
buffer.append(", ");
if (update.isUseColumnsBrackets()) {
buffer.append("(");
for (int i = 0; i < update.getColumns().size(); i++) {
if (i != 0) {
buffer.append(", ");
Column column = update.getColumns().get(i);
column.accept(expressionVisitor);
if (update.isUseColumnsBrackets()) {
buffer.append(")");
Select select = update.getSelect();
select.getSelectBody().accept(selectVisitor);
buffer.append(")");
代码示例来源:origin: baomidou/mybatis-plus
/**
* update 语句处理
*/
@Override
public void processUpdate(Update update) {
List<Table> tableList = update.getTables();
Assert.isTrue(null != tableList && tableList.size() < 2,
"Failed to process multiple-table update, please exclude the statementId");
Table table = tableList.get(0);
if (tenantHandler.doTableFilter(table.getName())) {
// 过滤退出执行
return;
}
update.setWhere(this.andExpression(table, update.getWhere()));
}
代码示例来源:origin: JSQLParser/JSqlParser
final public Update Update() throws ParseException {Update update = new Update();
Table table = null;
List<Table> tables = new ArrayList<Table>();
update.setUseSelect(true);
select = Select();
jj_consume_token(200);
case K_WHERE:{
where = WhereClause();
update.setWhere(where);
break;
case K_ORDER:{
orderByElements = OrderByElements();
update.setOrderByElements(orderByElements);
break;
case K_LIMIT:{
limit = PlainLimit();
update.setLimit(limit);
break;
case 201:{
jj_consume_token(201);
update.setReturningAllColumns(true);
break;
update.setColumns(columns);
update.setExpressions(expList);
代码示例来源:origin: alibaba/mdrill
public void deParse(Update update) {
buffer.append("UPDATE " + update.getTable().getWholeTableName() + " SET ");
for (int i = 0; i < update.getColumns().size(); i++) {
Column column = (Column) update.getColumns().get(i);
buffer.append(column.getWholeColumnName() + "=");
Expression expression = (Expression) update.getExpressions().get(i);
expression.accept(expressionVisitor);
if (i < update.getColumns().size() - 1) {
buffer.append(", ");
}
}
if (update.getWhere() != null) {
buffer.append(" WHERE ");
update.getWhere().accept(expressionVisitor);
}
}
代码示例来源:origin: JSQLParser/JSqlParser
@Override
public void visit(Update update) {
for (Table table : update.getTables()) {
visit(table);
}
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);
}
}
代码示例来源:origin: com.eas.platypus/platypus-js-sql-parser
@Override
public String toString() {
String sql = getComment() != null ? getComment() + " " : "";
sql += "UPDATE ";
sql += getTable() + (getCommentSet() != null ? " " + getCommentSet() : "") + " SET ";
for (int i = 0; i < getColumns().size(); i++) {
sql += getColumns().get(i) + (!commentsEqaulas.get(i).toString().isEmpty() ? " " + commentsEqaulas.get(i) : "")
+ " = " + getExpressions().get(i);
if (i < getColumns().size() - 1) {
sql += (!commentsComma.get(i).toString().isEmpty() ? " " + commentsComma.get(i) : "") + ", ";
}
}
sql += (getCommentWhere() != null ? " " + getCommentWhere() : "") + " WHERE " + getWhere();
sql += !"".equals(getEndComment()) ? " " + getEndComment() : "";
return sql;
}
代码示例来源:origin: codingapi/tx-lcn
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 = tableStructAnalyser.analyse(connection, table.getName());
.setPrimaryKeys(primaryKeys)
.setTables(tables)
.setWhereSql(update.getWhere() == null ? "1=1" : update.getWhere().toString()));
} catch (TxcLogicException e) {
throw new SQLException(e.getMessage());
代码示例来源:origin: diennea/herddb
@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);
});
}
}
代码示例来源:origin: baomidou/mybatis-plus
} else if (statement instanceof Update) {
Update update = (Update) statement;
where = update.getWhere();
table = update.getTables().get(0);
joins = update.getJoins();
} else if (statement instanceof Delete) {
Delete delete = (Delete) statement;
代码示例来源:origin: alibaba/mdrill
final public Update Update() throws ParseException {
Update update = new Update();
Table table = null;
Expression where = null;
case K_WHERE:
where = WhereClause();
update.setWhere(where);
break;
default:
update.setColumns(columns);
update.setExpressions(expList);
update.setTable(table);
{if (true) return update;}
throw new Error("Missing return statement in function");
代码示例来源:origin: JSQLParser/JSqlParser
@Override
public String toString() {
StringBuilder b = new StringBuilder("UPDATE ");
b.append(PlainSelect.getStringList(getTables(), true, false)).append(" SET ");
for (int i = 0; i < getColumns().size(); i++) {
if (i != 0) {
b.append(", ");
b.append("(");
for (int i = 0; i < getColumns().size(); i++) {
if (i != 0) {
b.append(", ");
if (isReturningAllColumns()) {
b.append(" RETURNING *");
} else if (getReturningExpressionList() != null) {
b.append(" RETURNING ").append(PlainSelect.
getStringList(getReturningExpressionList(), true, false));
代码示例来源:origin: erdemcer/kafka-connect-oracle
for (Column c : update.getColumns()){
dataMap.put(cleanString(c.getColumnName()), null);
Iterator<Expression> iterator = update.getExpressions().iterator();
update.getWhere().accept(new ExpressionVisitorAdapter() {
@Override
public void visit(final EqualsTo expr){
代码示例来源:origin: com.eas.platypus/platypus-js-sql-parser
final public Update Update() throws ParseException {Update update = new Update();
Table table = null;
Expression where = null;
update.setComment(tk.specialToken.image);
update.setCommentSet(tk.specialToken.image);
columns.add(tableColumn); expList.add(value);
update.setCommentsComma(commentsComma);
update.setCommentsEqaulas(commentsEqaulas);
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case K_WHERE:{
tk = jj_consume_token(K_WHERE);
if (tk.specialToken != null) {
update.setCommentWhere(tk.specialToken.image);
update.setWhere(where);
break;
update.setColumns(columns);
update.setExpressions(expList);
update.setTable(table);
{if ("" != null) return update;}
throw new Error("Missing return statement in function");
代码示例来源:origin: baomidou/mybatis-plus
@Override
public void processUpdate(Update update) {
Assert.notNull(update.getWhere(), "Prohibition of table update operation");
}
代码示例来源:origin: wxbty/meepo
public static List<String> name_update_table(String sql) throws JSQLParserException {
net.sf.jsqlparser.statement.Statement statement = CCJSqlParserUtil.parse(sql);
Update updateStatement = (Update) statement;
List<Table> update_table = updateStatement.getTables();
List<String> str_table = new ArrayList<>();
if (update_table != null) {
for (int i = 0; i < update_table.size(); i++) {
str_table.add(update_table.get(i).toString());
}
}
return str_table;
}
代码示例来源:origin: yidasanqian/dynamic-add-date
List<Table> tableList = update.getTables();
for (Table table : tableList) {
if (!matchesIgnoreTables(table.getName())) {
boolean isContainsModifyDateColumn = false;
int modifyDateColumnIndex = 0;
for (int i = 0; i < update.getColumns().size(); i++) {
Column column = update.getColumns().get(i);
if (column.getColumnName().equals(updateDateColumnName)) {
isContainsModifyDateColumn = true;
logger.debug("intercept 更新sql : " + update.toString());
metaObject.setValue("delegate.boundSql.sql", update.toString());
List<Table> tableList = update.getTables();
for (Table table : tableList) {
if (!matchesIgnoreTables(table.getName())) {
代码示例来源:origin: Mearalu/mybatis-multi-tenancy
/**
* update语句处理
* TODO 因为线上系统不允许更改数据租户,所以并未实现它
*
* @param update
*/
@Override
public void processUpdate(Update update) {
//获得where条件表达式
Expression where = update.getWhere();
EqualsTo equalsTo = new EqualsTo();
if (where instanceof BinaryExpression) {
equalsTo.setLeftExpression(new Column(this.tenantInfo.getTenantIdColumn()));
equalsTo.setRightExpression(new StringValue("," + tenantInfo.getTenantId() + ","));
AndExpression andExpression = new AndExpression(equalsTo, where);
update.setWhere(andExpression);
}else{
equalsTo.setLeftExpression(new Column(this.tenantInfo.getTenantIdColumn()));
equalsTo.setRightExpression(new StringValue("," + tenantInfo.getTenantId() + ","));
update.setWhere(equalsTo);
}
}
代码示例来源:origin: yidasanqian/dynamic-add-date
private void updateValue(String updateDateColumnName, String currentDate, Update update) {
// 添加列
update.getColumns().add(new Column(updateDateColumnName));
update.getExpressions().add(new QuotationTimestampValue(currentDate));
}
代码示例来源:origin: wxbty/meepo
public static List<String> name_update_column(String sql) throws JSQLParserException {
net.sf.jsqlparser.statement.Statement statement = CCJSqlParserUtil.parse(sql);
Update updateStatement = (Update) statement;
List<Column> update_column = updateStatement.getColumns();
List<String> str_column = new ArrayList<>();
if (update_column != null) {
for (int i = 0; i < update_column.size(); i++) {
str_column.add(update_column.get(i).toString());
}
}
return str_column;
}
代码示例来源:origin: yidasanqian/dynamic-add-date
private void updateValueWithIndex(int modifyDateColumnIndex, String currentDate, Update update) {
update.getExpressions().set(modifyDateColumnIndex, new QuotationTimestampValue(currentDate));
}
内容来源于网络,如有侵权,请联系作者删除!