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


Java Delete类代码示例

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


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

示例1: createSelect

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
private static Select createSelect(CloudSpannerConnection connection, Delete delete) throws SQLException
{
	TableKeyMetaData table = connection.getTable(CloudSpannerDriver.unquoteIdentifier(delete.getTable().getName()));
	List<String> keyCols = table.getKeyColumns().stream()
			.map(x -> CloudSpannerDriver.quoteIdentifier(delete.getTable().getName()) + "."
					+ CloudSpannerDriver.quoteIdentifier(x))
			.collect(Collectors.toList());
	StringBuilder sql = new StringBuilder();
	sql.append("SELECT ").append(String.join(", ", keyCols));
	sql.append("\nFROM ").append(CloudSpannerDriver.quoteIdentifier(delete.getTable().getName()));
	sql.append("\nWHERE ").append(delete.getWhere().toString());

	try
	{
		return (Select) CCJSqlParserUtil.parse(sql.toString());
	}
	catch (JSQLParserException e)
	{
		throw new CloudSpannerSQLException("Could not parse generated SELECT statement: " + sql,
				Code.INVALID_ARGUMENT);
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:23,代码来源:DeleteWorker.java

示例2: createDeleteMutation

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
private Mutation createDeleteMutation(Delete delete, boolean generateParameterMetaData) throws SQLException
{
	String table = unquoteIdentifier(delete.getTable().getFullyQualifiedName());
	getParameterStore().setTable(table);
	Expression where = delete.getWhere();
	if (where == null)
	{
		// Delete all
		return Mutation.delete(table, KeySet.all());
	}
	else
	{
		// Delete one
		DeleteKeyBuilder keyBuilder = new DeleteKeyBuilder(getConnection().getTable(table),
				generateParameterMetaData);
		visitDeleteWhereClause(where, keyBuilder, generateParameterMetaData);
		return Mutation.delete(table, keyBuilder.getKeyBuilder().build());
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:20,代码来源:CloudSpannerPreparedStatement.java

示例3: JSQLParserAdapter

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的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

示例4: visit

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
/**
 * mysql 'delete' doesn't support alais
 */
@Override
public void visit(Delete delete) {
    if (enableLimitCheck && delete.getLimit() == null) {
        throw new IllegalStateException("no limit in sql: " + sql);
    }
    this.getStack().push(new FrameContext());
    ShardRouteConfig routeConfig = shardRouter.getRouteConfig(delete.getTable().getSchemaName(),
                                                              delete.getTable().getName());
    if (routeConfig != null) {
        TableWrapper tab = new TableWrapper(delete.getTable(), routeConfig);
        delete.setTable(tab);
        addRoutedTableIntoContext(tab, routeConfig, false);
    }
    super.visit(delete);
    afterVisitBaseStatement();
}
 
开发者ID:hellojavaer,项目名称:ddal,代码行数:20,代码来源:JSQLParserAdapter.java

示例5: visit

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
@Override
public synchronized void visit(Delete del) {
   controlEventMap.put(sql, ControlEvent.DELETE);
   targetMap.put(sql, del.getTable().getName());

   List<SqlParameter> paramList = new ArrayList<SqlParameter>();
   parameterMap.put(sql, paramList);
   List<SqlParameter> updList = new ArrayList<SqlParameter>();
   insUpdColumnsMap.put(sql, updList);

   parseWhere(del.getWhere(), 0);
   if (primaryKeys.get(sql) == null) {
      // no unique primary key condition. Not controlled
      controlEventMap.put(sql, null);
      emptyPrimaryKey(SqlParameterType.WHERE_PARAMETER);
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:18,代码来源:SqlParser.java

示例6: parse

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

示例7: parseVerifyQuery

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
@Override
protected Statement parseVerifyQuery(Delete delete) {
    // We verify delete so that we can revoke all deleted serial numbers
    Table table = delete.getTable();

    // Get all columns, because we are deleting the entire row
    Select select = SelectUtils.buildSelectFromTableAndSelectItems(table, new AllColumns());

    // Apply the where clause to the SELECT
    PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
    plainSelect.setWhere(delete.getWhere());

    plainSelect.setLimit(delete.getLimit());
    plainSelect.setOrderByElements(delete.getOrderByElements());

    return select;
}
 
开发者ID:Hyperparticle,项目名称:integrity-coded-database,代码行数:18,代码来源:OCFQuery.java

示例8: parseVerifyQuery

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
@Override
protected Statement parseVerifyQuery(Delete delete) {
    // We verify delete so that we can revoke all deleted serial numbers
    Table table = delete.getTable();

    Select select = SelectUtils.buildSelectFromTableAndSelectItems(table, new AllColumns());

    // Apply the where clause to the SELECT
    PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
    plainSelect.setWhere(delete.getWhere());

    plainSelect.setLimit(delete.getLimit());
    plainSelect.setOrderByElements(delete.getOrderByElements());

    return select;
}
 
开发者ID:Hyperparticle,项目名称:integrity-coded-database,代码行数:17,代码来源:OCTQuery.java

示例9: checkParseAndDeparse

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
public void checkParseAndDeparse(String statementText) throws JSQLParserException {
    Statement statement = parserManager.parse(new StringReader(statementText));
    assertNotNull(statement);
    StringBuilder buffer = new StringBuilder();
    StatementDeParser deparser = new StatementDeParser(buffer);
    if (statement instanceof Select) {
        deparser.visit((Select) statement);
    } else if (statement instanceof Delete) {
        deparser.visit((Delete) statement);
    } else if (statement instanceof Insert) {
        deparser.visit((Insert) statement);
    } else {
        throw new JSQLParserException("Unknown type of parsed statement");
    }
    assertEquals(buffer.toString().toLowerCase().replaceAll(ExpressionDeParser.LINE_SEPARATOR, ""), statementText.toLowerCase().replaceAll(ExpressionDeParser.LINE_SEPARATOR, ""));
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:17,代码来源:GeneralTest.java

示例10: getParameterMetaData

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的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: createDeleteWorker

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
private DeleteWorker createDeleteWorker(Delete delete) throws SQLException
{
	if (delete.getTable() == null || (delete.getTables() != null && delete.getTables().size() > 0))
	{
		throw new CloudSpannerSQLException("DELETE statement must contain only one table", Code.INVALID_ARGUMENT);
	}
	return new DeleteWorker(getConnection(), delete, getConnection().isAllowExtendedMode());
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:9,代码来源:CloudSpannerPreparedStatement.java

示例12: visit

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
@Override
public void visit(Delete delete) {
    SelectDeParser selectDeParser = new SelectDeParser();
    selectDeParser.setBuffer(buffer);
    ExpressionDeParser expressionDeParser = new ExpressionDeParser(selectDeParser, buffer);
    selectDeParser.setExpressionVisitor(expressionDeParser);
    DeleteDeParser deleteDeParser = new DeleteDeParser(expressionDeParser, buffer);
    deleteDeParser.deParse(delete);
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:10,代码来源:StatementDeParser.java

示例13: deParse

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
public void deParse(Delete delete) {
	buffer.append("DELETE");
	if(delete.getTables() != null && delete.getTables().size() > 0){
		for( Table table : delete.getTables() ){
			buffer.append(" ").append(table.getFullyQualifiedName());
		}
	}
	buffer.append(" FROM ").append(delete.getTable().toString());
	
	if (delete.getJoins() != null) {
           for (Join join : delete.getJoins()) {
               if (join.isSimple()) {
                   buffer.append(", ").append(join);
               } else {
                   buffer.append(" ").append(join);
               }
           }
       }
	
	if (delete.getWhere() != null) {
		buffer.append(" WHERE ");
		delete.getWhere().accept(expressionVisitor);
	}

	if(delete.getOrderByElements()!=null){
		new OrderByDeParser(expressionVisitor, buffer).deParse(delete.getOrderByElements());
	}
	if (delete.getLimit() != null) {
		new LimitDeparser(buffer).deParse(delete.getLimit());
	}

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

示例14: visit

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
@Override
public void visit(Delete delete) {
    tables.add(delete.getTable().getName());
    if (delete.getWhere() != null) {
        delete.getWhere().accept(this);
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:8,代码来源:TablesNamesFinder.java

示例15: visit

import net.sf.jsqlparser.statement.delete.Delete; //导入依赖的package包/类
@Override
public void visit(Delete delete) {
    tables.add(delete.getTable(), table -> table.getName());
    if (delete.getWhere() != null) {
        delete.getWhere().accept(this);
    }
}
 
开发者ID:justice-code,项目名称:QiuQiu,代码行数:8,代码来源:ReplaceTablesNamesFinder.java


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