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


Java SubSelect类代码示例

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


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

示例1: parseExpression

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
protected Set<String> parseExpression(Expression expression) {
	Set<String> expTableSet = new HashSet<String>();
	if (expression instanceof BinaryExpression) {
		expTableSet.addAll(parseExpression(((BinaryExpression)expression).getLeftExpression()));
		expTableSet.addAll(parseExpression(((BinaryExpression)expression).getRightExpression()));
	}
	
	if (expression instanceof InExpression) {
		ItemsList itemList = ((InExpression)expression).getRightItemsList();
		if (itemList instanceof SubSelect) {
			SubSelect subSelect = (SubSelect)itemList;
			expTableSet.addAll(parse(subSelect.getSelectBody()));
		}
	}
	
	return expTableSet;
}
 
开发者ID:PinaeOS,项目名称:timon,代码行数:18,代码来源:SelectParser.java

示例2: visit

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
@Override
public void visit(SubSelect subSelect) {
    buffer.append("(");
    if (subSelect.getWithItemsList() != null && !subSelect.getWithItemsList().isEmpty()) {
        buffer.append("WITH ");
        for (Iterator<WithItem> iter = subSelect.getWithItemsList().iterator(); iter.hasNext();) {
            WithItem withItem = iter.next();
            withItem.accept(this);
            if (iter.hasNext()) {
                buffer.append(",");
            }
            buffer.append(" ");
        }
    }
    subSelect.getSelectBody().accept(this);
    buffer.append(")");
    Pivot pivot = subSelect.getPivot();
    if (pivot != null) {
        pivot.accept(this);
    }
    Alias alias = subSelect.getAlias();
    if (alias != null) {
        buffer.append(alias.toString());
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:26,代码来源:SelectDeParser.java

示例3: CompiledInExpression

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
public CompiledInExpression(boolean not, CompiledSQLExpression left,
        List<CompiledSQLExpression> inExpressions, SubSelect inSubSelect) {
    this.left = left;
    this.not = not;
    this.inExpressions = inExpressions;
    if (inSubSelect != null) {
        if (inSubSelect.getSelectBody() instanceof PlainSelect) {
            this.inSubSelectPlain = (PlainSelect) inSubSelect.getSelectBody();
        } else {
            throw new StatementExecutionException("unsupported operand \"IN\""
                    + " with subquery of type " + inSubSelect.getSelectBody().getClass()
                    + "(" + inSubSelect.getSelectBody() + ")");
        }
    } else {
        this.inSubSelectPlain = null;
    }
}
 
开发者ID:diennea,项目名称:herddb,代码行数:18,代码来源:CompiledInExpression.java

示例4: testInsertFromSelect

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
@Test
public void testInsertFromSelect() throws JSQLParserException {
    String statement = "INSERT INTO mytable t (col1, col2, col3) SELECT * FROM mytable2";
    Insert insert = (Insert) parserManager.parse(new StringReader(statement));
    assertEquals("mytable", insert.getTable().getName());
    assertEquals(3, insert.getColumns().size());
    assertEquals("col1", ((Column) insert.getColumns().get(0)).getColumnName());
    assertEquals("col2", ((Column) insert.getColumns().get(1)).getColumnName());
    assertEquals("col3", ((Column) insert.getColumns().get(2)).getColumnName());
    assertTrue(insert.getItemsList() instanceof SubSelect);
    assertEquals("mytable2", ((Table) ((PlainSelect) ((SubSelect) insert.getItemsList()).getSelectBody()).getFromItem()).getName());

    //toString uses brakets
    String statementToString = "INSERT INTO mytable t (col1, col2, col3) (SELECT * FROM mytable2)";
    assertEquals(statementToString, "" + insert);
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:17,代码来源:InsertTest.java

示例5: getColumnsFromSubSelect

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
private List<ProjectionItem> getColumnsFromSubSelect(SubSelect subSelect) throws NoSuchTableException, AmbiguousCoalesceException {
	SelectBody subSelectBody = subSelect.getSelectBody();
	if (subSelectBody instanceof PlainSelect) {
		List<ProjectionItem> subSelectProjections = getProjections((PlainSelect) subSelectBody);
		
		if (subSelect.getAlias() != null) {
			String subSelectAlias = subSelect.getAlias();
			for (ProjectionItem subSelectProjection : subSelectProjections) {
				subSelectProjection.setBaseTable(subSelectAlias);
			}
		}
		
		return subSelectProjections;
	} else {
		throw new RuntimeException("Not supported");
	}
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:18,代码来源:QueryTypeExtractor.java

示例6: visit

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
@Override
public void visit(SubSelect ss) {
    if (ss.getAlias() == null || ss.getAlias().getName() == null) {
        throw new QueryException("Subselect alias not defined: %s", ss.toString());
    }

    String alias = ss.getAlias().getName();
    if (selectDef.getTop().hasAlias(alias)) {
        throw new QueryException("Duplicate table alias: %s", alias);
    }
    
    CheckSelectParser sp = rf.createSelectParser(selectDef);
    selectDef.getTables().put(alias, sp.getSelectDef());
    ss.getSelectBody().accept(sp);
    
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:17,代码来源:CheckSelectParser.java

示例7: withSelect

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
public SelectMongoCommand withSelect(PlainSelect select) {
    this.select = select;
    this.select.getFromItem().accept(new FromItemVisitor() {
        @Override
        public void visit(SubJoin subJoin) {
        }

        @Override
        public void visit(SubSelect subSelect) {
        }

        @Override
        public void visit(Table table) {
            collection = table.getName();
        }
    });
    return this;
}
 
开发者ID:mulesoft-labs,项目名称:mongo-sql-console,代码行数:19,代码来源:SelectMongoCommand.java

示例8: setWhereParameters

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
private void setWhereParameters(Expression where, com.google.cloud.spanner.Statement.Builder builder)
{
	if (where != null)
	{
		where.accept(new ExpressionVisitorAdapter()
		{
			private String currentCol = null;

			@Override
			public void visit(Column col)
			{
				currentCol = unquoteIdentifier(col.getFullyQualifiedName());
			}

			@Override
			public void visit(JdbcParameter parameter)
			{
				parameter.accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
						builder.bind("p" + parameter.getIndex()), currentCol));
				currentCol = null;
			}

			@Override
			public void visit(SubSelect subSelect)
			{
				setSelectParameters(subSelect.getSelectBody(), builder);
			}

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

示例9: visit

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
@Override
public void visit(SubSelect subSelect) {
    if (selectVisitor != null) {
        for (WithItem item : subSelect.getWithItemsList()) {
            item.accept(selectVisitor);
        }
        subSelect.getSelectBody().accept(selectVisitor);
    }
    if (subSelect.getPivot() != null) {
        subSelect.getPivot().accept(this);
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:13,代码来源:ExpressionVisitorAdapter.java

示例10: visit

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
@Override
public void visit(SubSelect subSelect) {
    buffer.append("(");
    if (selectVisitor != null) {
        subSelect.getSelectBody().accept(selectVisitor);
    }
    buffer.append(")");
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:9,代码来源:ExpressionDeParser.java

示例11: visit

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
@Override
public void visit(SubSelect subSelect) {
    if (subSelect.getWithItemsList() != null) {
        for (WithItem withItem : subSelect.getWithItemsList()) {
            withItem.accept(this);
        }
    }
    subSelect.getSelectBody().accept(this);
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:10,代码来源:TablesNamesFinder.java

示例12: create

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
public static CompiledInExpression create(InExpression in, String validatedTableAlias) {
    if (in.getLeftItemsList() != null) {
        throw new StatementExecutionException("Unsupported operand " + in.getClass() + " with a non-expression left argument (" + in + ")");
    }
    CompiledSQLExpression left = compileExpression(validatedTableAlias, in.getLeftExpression());
    if (left == null) {
        return null;
    }

    if (in.getRightItemsList() instanceof ExpressionList) {
        List<CompiledSQLExpression> expList = new ArrayList<>();
        ExpressionList exps = (ExpressionList) in.getRightItemsList();
        for (Expression exp : exps.getExpressions()) {
            CompiledSQLExpression newExp = compileExpression(validatedTableAlias, exp);
            if (newExp == null) {
                return null;
            }
            expList.add(newExp);
        }
        return new CompiledInExpression(in.isNot(), left, expList, null);
    }

    if (in.getRightItemsList() instanceof SubSelect) {
        SubSelect ss = (SubSelect) in.getRightItemsList();
        if (!(ss.getSelectBody() instanceof PlainSelect)) {
            throw new StatementExecutionException("unsupported operand " + in.getClass()
                    + " with subquery of type " + ss.getClass() + "(" + ss + ")");
        }
        return new CompiledInExpression(in.isNot(), left, null, ss);
    }

    throw new StatementExecutionException("unsupported operand " + in.getClass()
            + " with argument of type " + in.getRightItemsList().getClass() + "(" + in + ")");
}
 
开发者ID:diennea,项目名称:herddb,代码行数:35,代码来源:CompiledInExpression.java

示例13: visit

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
@Override
public void visit(InExpression inExpression) {
    inExpression.getLeftExpression().accept(this);
    if (inExpression.getLeftItemsList() != null) {
        inExpression.getLeftItemsList().accept(this);
    }
    if (inExpression.getRightItemsList() instanceof SubSelect) {
        SubSelect ss = (SubSelect) inExpression.getRightItemsList();
        if (!(ss.getSelectBody() instanceof PlainSelect)) {
            throw new StatementExecutionException("unsupported operand " + inExpression.getClass()
                + " with subquery of type " + ss.getClass() + "(" + ss + ")");
        }
        visit(ss);
    }
}
 
开发者ID:diennea,项目名称:herddb,代码行数:16,代码来源:JdbcQueryRewriter.java

示例14: SubSelect

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
final public SubSelect SubSelect() throws ParseException {
      SelectBody selectBody = null;
  selectBody = SelectBody();
      SubSelect subSelect = new SubSelect();
      subSelect.setSelectBody(selectBody);
      {if (true) return subSelect;}
  throw new Error("Missing return statement in function");
}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:9,代码来源:CCJSqlParser.java

示例15: testInsertFromSelect

import net.sf.jsqlparser.statement.select.SubSelect; //导入依赖的package包/类
public void testInsertFromSelect() throws JSQLParserException {
	String statement = "INSERT INTO mytable (col1, col2, col3) SELECT * FROM mytable2";
	Insert insert = (Insert) parserManager.parse(new StringReader(statement));
	assertEquals("mytable", insert.getTable().getName());
	assertEquals(3, insert.getColumns().size());
	assertEquals("col1", ((Column) insert.getColumns().get(0)).getColumnName());
	assertEquals("col2", ((Column) insert.getColumns().get(1)).getColumnName());
	assertEquals("col3", ((Column) insert.getColumns().get(2)).getColumnName());
	assertTrue (insert.getItemsList() instanceof SubSelect);
	assertEquals("mytable2", ((Table) ((PlainSelect) ((SubSelect)insert.getItemsList()).getSelectBody()).getFromItem()).getName());
	
	//toString uses brakets
	String statementToString = "INSERT INTO mytable (col1, col2, col3) (SELECT * FROM mytable2)";
	assertEquals(statementToString, ""+insert);
}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:16,代码来源:InsertTest.java


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