本文整理汇总了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;
}
示例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());
}
}
示例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;
}
}
示例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);
}
示例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");
}
}
示例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);
}
示例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;
}
示例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);
}
});
}
}
示例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);
}
}
示例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(")");
}
示例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);
}
示例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 + ")");
}
示例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);
}
}
示例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");
}
示例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);
}