本文整理汇总了Java中net.sf.jsqlparser.statement.insert.Insert.getSelect方法的典型用法代码示例。如果您正苦于以下问题:Java Insert.getSelect方法的具体用法?Java Insert.getSelect怎么用?Java Insert.getSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jsqlparser.statement.insert.Insert
的用法示例。
在下文中一共展示了Insert.getSelect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInsertWithSelectStatement
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的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);
}
示例2: visit
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的package包/类
@Override
public void visit(Insert s) {
visit(s.getTable());
if (s.getColumns() != null) {
s.getColumns().forEach(c -> {
c.accept(this);
});
}
if (s.getItemsList() != null) {
s.getItemsList().accept(this);
}
if (s.getSelect() != null) {
s.getSelect().accept(this);
}
if (s.getReturningExpressionList() != null) {
s.getReturningExpressionList().forEach(o -> {
o.accept(this);
});
}
}
示例3: processInsert
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的package包/类
/**
* <p>
* insert 语句处理
* </p>
*/
@Override
public void processInsert(Insert insert) {
if (this.tenantHandler.doTableFilter(insert.getTable().getName())) {
// 过滤退出执行
return;
}
insert.getColumns().add(new Column(this.tenantHandler.getTenantIdColumn()));
if (insert.getSelect() != null) {
processPlainSelect((PlainSelect) insert.getSelect().getSelectBody(), true);
} else if (insert.getItemsList() != null) {
((ExpressionList) insert.getItemsList()).getExpressions().add(tenantHandler.getTenantId());
} else {
throw new MybatisPlusException("Failed to process multiple-table update, please exclude the tableName or statementId");
}
}
示例4: visit
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的package包/类
@Override
public void visit(Insert insert) {
tables.add(insert.getTable().getName());
if (insert.getItemsList() != null) {
insert.getItemsList().accept(this);
}
if (insert.getSelect() != null) {
visit(insert.getSelect());
}
}
示例5: visit
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的package包/类
@Override
public void visit(Insert insert) {
tables.add(insert.getTable(), table -> table.getName());
if (insert.getItemsList() != null) {
insert.getItemsList().accept(this);
}
if (insert.getSelect() != null) {
visit(insert.getSelect());
}
}
示例6: visit
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的package包/类
@Override
public void visit(Insert insert) {
if (insert.getItemsList() != null) {
insert.getItemsList().accept(this);
}
if (insert.getSelect() != null) {
visit(insert.getSelect());
}
}
示例7: visit
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的package包/类
@Override
public void visit(Insert insert)
{
insert.getTable().accept(this);
if (insert.getItemsList() != null)
{
insert.getItemsList().accept(this);
}
if (insert.getSelect() != null)
{
visit(insert.getSelect());
}
}
示例8: createMutations
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的package包/类
private Mutations createMutations(String sql, boolean forceUpdate, boolean generateParameterMetaData)
throws SQLException
{
try
{
if (getConnection().isReadOnly())
{
throw new CloudSpannerSQLException("The connection is in read-only mode. Mutations are not allowed.",
Code.FAILED_PRECONDITION);
}
if (isDDLStatement())
{
throw new CloudSpannerSQLException(
"Cannot create mutation for DDL statement. Expected INSERT, UPDATE or DELETE",
Code.INVALID_ARGUMENT);
}
Statement statement = CCJSqlParserUtil.parse(sanitizeSQL(sql));
if (statement instanceof Insert)
{
Insert insertStatement = (Insert) statement;
if (generateParameterMetaData || insertStatement.getSelect() == null)
return new Mutations(createInsertMutation(insertStatement, generateParameterMetaData));
return new Mutations(createInsertWithSelectStatement(insertStatement, forceUpdate));
}
else if (statement instanceof Update)
{
Update updateStatement = (Update) statement;
if (updateStatement.getSelect() != null)
throw new CloudSpannerSQLException(
"UPDATE statement using SELECT is not supported. Try to re-write the statement as an INSERT INTO ... SELECT A, B, C FROM TABLE WHERE ... ON DUPLICATE KEY UPDATE",
Code.INVALID_ARGUMENT);
if (updateStatement.getTables().size() > 1)
throw new CloudSpannerSQLException(
"UPDATE statement using multiple tables is not supported. Try to re-write the statement as an INSERT INTO ... SELECT A, B, C FROM TABLE WHERE ... ON DUPLICATE KEY UPDATE",
Code.INVALID_ARGUMENT);
if (generateParameterMetaData || isSingleRowWhereClause(
getConnection().getTable(unquoteIdentifier(updateStatement.getTables().get(0).getName())),
updateStatement.getWhere()))
return new Mutations(createUpdateMutation(updateStatement, generateParameterMetaData));
// Translate into an 'INSERT ... SELECT ... ON DUPLICATE KEY
// UPDATE'-statement
String insertSQL = createInsertSelectOnDuplicateKeyUpdateStatement(updateStatement);
return createMutations(insertSQL, true, false);
}
else if (statement instanceof Delete)
{
Delete deleteStatement = (Delete) statement;
if (generateParameterMetaData || deleteStatement.getWhere() == null
|| isSingleRowWhereClause(
getConnection().getTable(unquoteIdentifier(deleteStatement.getTable().getName())),
deleteStatement.getWhere()))
return new Mutations(createDeleteMutation(deleteStatement, generateParameterMetaData));
return new Mutations(createDeleteWorker(deleteStatement));
}
else
{
throw new CloudSpannerSQLException(
"Unrecognized or unsupported SQL-statment: Expected one of INSERT, UPDATE or DELETE. Please note that batching of prepared statements is not supported for SELECT-statements.",
Code.INVALID_ARGUMENT);
}
}
catch (JSQLParserException | IllegalArgumentException | TokenMgrError e)
{
throw new CloudSpannerSQLException(PARSE_ERROR + sql + ": " + e.getLocalizedMessage(),
Code.INVALID_ARGUMENT, e);
}
}
示例9: createInsertMutation
import net.sf.jsqlparser.statement.insert.Insert; //导入方法依赖的package包/类
private Mutation createInsertMutation(Insert insert, boolean generateParameterMetaData) throws SQLException
{
ItemsList items = insert.getItemsList();
if (generateParameterMetaData && items == null && insert.getSelect() != null)
{
// Just initialize the parameter meta data of the select statement
createSelectBuilder(insert.getSelect(), insert.getSelect().toString());
return null;
}
if (!(items instanceof ExpressionList))
{
throw new CloudSpannerSQLException("Insert statement must specify a list of values", Code.INVALID_ARGUMENT);
}
if (insert.getColumns() == null || insert.getColumns().isEmpty())
{
throw new CloudSpannerSQLException("Insert statement must specify a list of column names",
Code.INVALID_ARGUMENT);
}
List<Expression> expressions = ((ExpressionList) items).getExpressions();
String table = unquoteIdentifier(insert.getTable().getFullyQualifiedName());
getParameterStore().setTable(table);
WriteBuilder builder;
if (insert.isUseDuplicate())
{
/**
* Do an insert-or-update. BUT: Cloud Spanner does not support
* supplying different values for the insert and update statements,
* meaning that only the values specified in the INSERT part of the
* statement will be considered. Anything specified in the 'ON
* DUPLICATE KEY UPDATE ...' statement will be ignored.
*/
if (this.forceUpdate)
builder = Mutation.newUpdateBuilder(table);
else
builder = Mutation.newInsertOrUpdateBuilder(table);
}
else
{
/**
* Just do an insert and throw an error if a row with the specified
* key alread exists.
*/
builder = Mutation.newInsertBuilder(table);
}
int index = 0;
for (Column col : insert.getColumns())
{
String columnName = unquoteIdentifier(col.getFullyQualifiedName());
expressions.get(index).accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
builder.set(columnName), columnName));
index++;
}
return builder.build();
}