net.sf.jsqlparser.statement.select.Join类的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(530)

本文整理了Java中net.sf.jsqlparser.statement.select.Join类的一些代码示例,展示了Join类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Join类的具体详情如下:
包路径:net.sf.jsqlparser.statement.select.Join
类名称:Join

Join介绍

[英]A join clause
[中]连接子句

代码示例

代码示例来源:origin: alibaba/mdrill

public void deparseJoin(Join join) {
  if (join.isSimple())
    buffer.append(", ");
  else
    if (join.isRight())
      buffer.append("RIGHT ");
    else if (join.isNatural())
      buffer.append("NATURAL ");
    else if (join.isFull())
      buffer.append("FULL ");
    else if (join.isLeft())
      buffer.append("LEFT ");
    if (join.isOuter())
      buffer.append("OUTER ");
    else if (join.isInner())
      buffer.append("INNER ");
  FromItem fromItem = join.getRightItem();
  fromItem.accept(this);
  if (join.getOnExpression() != null) {
    buffer.append(" ON ");
    join.getOnExpression().accept(expressionVisitor);
  if (join.getUsingColumns() != null) {
    buffer.append(" USING ( ");
    for (Iterator iterator = join.getUsingColumns().iterator(); iterator.hasNext();) {
      Column column = (Column) iterator.next();
      buffer.append(column.getWholeColumnName());

代码示例来源:origin: JSQLParser/JSqlParser

boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
  jjtn000.jjtSetFirstToken(getToken(1));Join join = new Join();
  FromItem right = null;
  Expression onExpression = null;
    case K_LEFT:{
     jj_consume_token(K_LEFT);
join.setLeft(true);
     switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
     case K_OUTER:
      case K_SEMI:{
       jj_consume_token(K_SEMI);
join.setSemi(true);
       break;
join.setOuter(true);
       break;
     case K_RIGHT:{
      jj_consume_token(K_RIGHT);
join.setRight(true);
      break;
join.setFull(true);
      break;
     case K_OUTER:{

代码示例来源:origin: alibaba/mdrill

public String toString() {
    if (isSimple())
      return "" + rightItem;
    else
    {
      String type = "";
  
      if (isRight())
        type += "RIGHT ";
      else if (isNatural())
        type += "NATURAL ";
      else if (isFull())
        type += "FULL ";
      else if (isLeft())
        type += "LEFT ";
      
      if (isOuter())
        type += "OUTER ";
      else if (isInner())
        type += "INNER ";

      return type +"JOIN " +
      rightItem+
      ((onExpression!=null)?" ON "+onExpression+"":"")+
      PlainSelect.getFormatedList(usingColumns, "USING", true, true);
    }
    
  }
}

代码示例来源:origin: baomidou/mybatis-plus

/**
 * 如果SQL用了 left Join,验证是否有or、not等等,并且验证是否使用了索引
 *
 * @param joins ignore
 * @param table ignore
 * @param connection ignore
 */
private static void validJoins(List<Join> joins, Table table, Connection connection) {
  //允许执行join,验证jion是否使用索引等等
  if (joins != null) {
    for (Join join : joins) {
      Table rightTable = (Table) join.getRightItem();
      Expression expression = join.getOnExpression();
      validWhere(expression, table, rightTable, connection);
    }
  }
}

代码示例来源:origin: JSQLParser/JSqlParser

@Override
public String toString() {
  if (isSimple()) {
    return "" + rightItem;
  } else {
    String type = "";
    if (isRight()) {
      type += "RIGHT ";
    } else if (isNatural()) {
      type += "NATURAL ";
    } else if (isFull()) {
      type += "FULL ";
    } else if (isLeft()) {
      type += "LEFT ";
    } else if (isCross()) {
      type += "CROSS ";
    if (isOuter()) {
      type += "OUTER ";
    } else if (isInner()) {
      type += "INNER ";
    } else if (isSemi()) {
      type += "SEMI ";

代码示例来源:origin: JSQLParser/JSqlParser

@Override
public void visit(SubJoin subjoin) {
  subjoin.getLeft().accept(this);
  for (Join join : subjoin.getJoinList()) {
    join.getRightItem().accept(this);
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-sql-parser

@Override
public String toString() {
  if (isSimple()) {
    return "" + (getComment() != null ? getComment() + " " : "") + rightItem;
  } else {
    String type = "";
    if (isRight()) {
      type += (getCommentRight() != null ? getCommentRight() + " " : "") + "RIGHT ";
    } else if (isNatural()) {
      type += (getCommentNatural() != null ? getCommentNatural() + " " : "") + "NATURAL ";
    } else if (isFull()) {
      type += (getCommentFull() != null ? getCommentFull() + " " : "") + "FULL ";
    } else if (isLeft()) {
      type += (getCommentLeft() != null ? getCommentLeft() + " " : "") + "LEFT ";
    }
    if (isOuter()) {
      type += (getCommentOuter() != null ? getCommentOuter() + " " : "") + "OUTER ";
    } else if (isInner()) {
      type += (getCommentInner() != null ? getCommentInner() + " " : "") + "INNER ";
    }
    return type + (getCommentJoin() != null ? getCommentJoin() + " " : "") + "JOIN "
        + rightItem
        + ((onExpression != null) ? (getCommentOn() != null ? " " + getCommentOn() : "") + " ON " + onExpression + "" : "")
        + (usingColumns != null ? ((getCommentUsing() != null ? " " + getCommentUsing() : "") + " USING "
        + (getCommentBeginBracket() != null ? getCommentBeginBracket() + " " : "")
        + PlainSelect.getStringListWithCommaComment(usingColumns, commentComma, true, true, getCommentEndBracket())) : "");
  }
}

代码示例来源:origin: JSQLParser/JSqlParser

public void deparseJoin(Join join) {
  if (join.isSimple()) {
    buffer.append(", ");
  } else {
    if (join.isRight()) {
      buffer.append(" RIGHT");
    } else if (join.isNatural()) {
      buffer.append(" NATURAL");
    } else if (join.isFull()) {
      buffer.append(" FULL");
    } else if (join.isLeft()) {
      buffer.append(" LEFT");
    } else if (join.isCross()) {
      buffer.append(" CROSS");
    if (join.isOuter()) {
      buffer.append(" OUTER");
    } else if (join.isInner()) {
      buffer.append(" INNER");
    } else if (join.isSemi()) {
      buffer.append(" SEMI");
  FromItem fromItem = join.getRightItem();
  fromItem.accept(this);
  if (join.isWindowJoin()) {
    buffer.append(" WITHIN ");
    buffer.append(join.getJoinWindow().toString());
  if (join.getOnExpression() != null) {

代码示例来源:origin: baomidou/mybatis-plus

/**
 * 处理联接语句
 */
protected void processJoin(Join join) {
  if (join.getRightItem() instanceof Table) {
    Table fromTable = (Table) join.getRightItem();
    if (this.tenantHandler.doTableFilter(fromTable.getName())) {
      // 过滤退出执行
      return;
    }
    join.setOnExpression(builderExpression(join.getOnExpression(), fromTable));
  }
}

代码示例来源:origin: alibaba/mdrill

final public Join JoinerExpression() throws ParseException {
   Join join = new Join();
   FromItem right = null;
   Expression onExpression = null;
  case K_LEFT:
   jj_consume_token(K_LEFT);
             join.setLeft(true);
   break;
  case K_RIGHT:
   jj_consume_token(K_RIGHT);
              join.setRight(true);
   break;
  case K_FULL:
   jj_consume_token(K_FULL);
              join.setFull(true);
   break;
  case K_NATURAL:
   jj_consume_token(K_NATURAL);
               join.setNatural(true);
   break;
  default:
  case K_OUTER:
   jj_consume_token(K_OUTER);
             join.setOuter(true);
   break;
  case K_INNER:
   jj_consume_token(K_INNER);
              join.setInner(true);

代码示例来源:origin: com.eas.platypus/platypus-js-sql-parser

final public Join JoinerExpression() throws ParseException {Join join = new Join();
    FromItem right = null;
    Expression onExpression = null;
    tk = jj_consume_token(K_LEFT);
if (tk.specialToken != null) {
     join.setCommentLeft(tk.specialToken.image);
        join.setLeft(true);
    break;
    tk = jj_consume_token(K_RIGHT);
if (tk.specialToken != null) {
     join.setCommentRight(tk.specialToken.image);
        join.setRight(true);
    break;
    tk = jj_consume_token(K_FULL);
if (tk.specialToken != null) {
     join.setCommentFull(tk.specialToken.image);
        join.setFull(true);
    break;
    tk = jj_consume_token(K_NATURAL);
if (tk.specialToken != null) {
     join.setCommentNatural(tk.specialToken.image);
        join.setNatural(true);

代码示例来源:origin: org.opencadc/cadc-adql

@SuppressWarnings("unchecked")
protected void navigateJoins()
{
  PlainSelect ps = this.plainSelect;
  List<Join> joins = ps.getJoins();
  if (joins != null)
  {
    for (Join join : joins)
    {
      FromItem fromItem = join.getRightItem();
      if (fromItem instanceof Table)
      {
        Table rightTable = (Table) join.getRightItem();
        rightTable.accept(this.fromItemNavigator);
        if (join.getOnExpression() != null) join.getOnExpression().accept(this.expressionNavigator);
        List<Column> columns = join.getUsingColumns();
        if (columns != null) for (Column column : columns)
          column.accept(this.expressionNavigator);
      }
      else if (fromItem instanceof SubSelect)
        throw new UnsupportedOperationException("sub-select not supported in FROM clause.");
    }
  }
}

代码示例来源:origin: Quetzal-RDF/quetzal

int nonPlaceHolderTables =getNumberNonPlaceHolderFromItem(plainSelect);
for (Join join: plainSelect.getJoins()) {
  if (join.getRightItem()!=null) {
    join.getRightItem().accept(visitor);
        res.getAlias().setUseAs(useASInTableAlias);
      join.setRightItem(res);
    if (join.isSimple() && useExplicitJoinSyntax) {
      join.setSimple(false);
      if (nonPlaceHolderTables>2 && plainSelect.getWhere()!=null) {
        throw new RuntimeException("3 way join or more not implemented yet!\n"+plainSelect);
      } else if (plainSelect.getWhere()!=null ) {
        String tableName = null;
        if (join.getRightItem() instanceof Table) {
          tableName = ((Table) join.getRightItem()).getFullyQualifiedName();
          if (join.getRightItem() instanceof Table) {
            rightTable = (Table) join.getRightItem();
          } else {
            assert join.getRightItem().getAlias()!=null;
            rightTable = new Table(join.getRightItem().getAlias().getName());
          join.setOnExpression(split.getOnExp());
          plainSelect.setWhere(split.getWhereExp());

代码示例来源:origin: codingapi/tx-lcn

if (join.isSimple()) {
  TableStruct rightTableStruct = tableStructAnalyser.analyse(connection, join.getRightItem().toString());
  rightTableStruct.getPrimaryKeys().forEach(primaryKey -> {
    Column column = new Column((Table) join.getRightItem(), primaryKey);
    selectItems.add(new SelectExpressionItem(column));
    primaryKeys.add(column.getFullyQualifiedName());

代码示例来源:origin: Quetzal-RDF/quetzal

@Override
public void visit(SubJoin subjoin) {
  if (subjoin.getLeft()!=null) {
    subjoin.getLeft().accept(this);
    subjoin.setLeft(result);
  }
  if (subjoin.getJoin().getRightItem()!=null) {
    FromItem right = subjoin.getJoin().getRightItem();
    right.accept(this);
    subjoin.getJoin().setRightItem(result);
  }
  result = subjoin;
  
}

代码示例来源:origin: Quetzal-RDF/quetzal

PlainSelect left = setOpList.getPlainSelects().get(0);
PlainSelect right = setOpList.getPlainSelects().get(1);
Join join = new Join();
join.setLeft(true);
join.setOuter(true);
FromItem rightFrom = right.getFromItem();
assert rightFrom instanceof Table;
Table  rightTable = (Table) rightFrom;
join.setRightItem(rightTable);
FromItem leftFrom = left.getFromItem();
assert leftFrom instanceof Table;
join.setOnExpression(onExp);
if (whereExp!=null) {
  if (left.getWhere()!=null) {

代码示例来源:origin: JSQLParser/JSqlParser

if (join.isSimple()) {
  b.append(", ").append(join);
} else {

代码示例来源:origin: JSQLParser/JSqlParser

/**
 * Adds a simple join to a select statement. The introduced join is returned for more
 * configuration settings on it (e.g. left join, right join).
 *
 * @param select
 * @param table
 * @param onExpression
 * @return
 */
public static Join addJoin(Select select, final Table table, final Expression onExpression) {
  if (select.getSelectBody() instanceof PlainSelect) {
    PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
    List<Join> joins = plainSelect.getJoins();
    if (joins == null) {
      joins = new ArrayList<Join>();
      plainSelect.setJoins(joins);
    }
    Join join = new Join();
    join.setRightItem(table);
    join.setOnExpression(onExpression);
    joins.add(join);
    return join;
  }
  throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
}

代码示例来源:origin: org.opencadc/cadc-adql

Expression e = join.getOnExpression();
Expression implExpression = convertToImplementation(e);
log.debug("PlainSelect/JOIN: replacing " + e + " with " + implExpression);
join.setOnExpression(implExpression);

代码示例来源:origin: pagehelper/Mybatis-PageHelper

/**
 * 处理PlainSelect类型的selectBody
 *
 * @param plainSelect
 */
public void processPlainSelect(PlainSelect plainSelect) {
  if (!orderByHashParameters(plainSelect.getOrderByElements())) {
    plainSelect.setOrderByElements(null);
  }
  if (plainSelect.getFromItem() != null) {
    processFromItem(plainSelect.getFromItem());
  }
  if (plainSelect.getJoins() != null && plainSelect.getJoins().size() > 0) {
    List<Join> joins = plainSelect.getJoins();
    for (Join join : joins) {
      if (join.getRightItem() != null) {
        processFromItem(join.getRightItem());
      }
    }
  }
}

相关文章