Package com.caucho.amber.expr

Examples of com.caucho.amber.expr.JoinExpr


  public FromItem createDependentFromItem(FromItem parent,
                                          LinkColumns link,
                                          String name)
  {
    for (int i = 0; i < _fromList.size(); i++) {
      JoinExpr join = _fromList.get(i).getJoinExpr();

      if (join != null && join.isDependent(parent, link))
        return _fromList.get(i);
    }

    FromItem item = createFromItem(null, link.getSourceTable(), name);

    JoinExpr join = new ManyToOneJoinExpr(link, item, parent);

    item.setJoinExpr(join);

    return item;
  }
View Full Code Here


      for (int i = components.size() - 1; i >= 0; i--) {
        AmberExpr component = components.get(i);

        if (component instanceof JoinExpr) {
          JoinExpr link = (JoinExpr) component;

          if (link.bindToFromItem()) {
            components.remove(i);
          }
        }
      }

      _where = and.getSingle();
    }

    if (_having instanceof AndExpr) {
      AndExpr and = (AndExpr) _having;

      ArrayList<AmberExpr> components = and.getComponents();

      for (int i = components.size() - 1; i >= 0; i--) {
        AmberExpr component = components.get(i);

        if (component instanceof JoinExpr) {
          JoinExpr link = (JoinExpr) component;

          if (link.bindToFromItem()) {
            components.remove(i);
          }
        }
      }

      _having = and.getSingle();
    }

    // Rolls up unused from items from the left to the right.
    // It's not necessary to roll up the rightmost items because
    // they're only created if they're actually needed
    for (int i = 0; i < _fromList.size(); i++) {
      FromItem item = _fromList.get(i);

      JoinExpr join = item.getJoinExpr();

      if (join == null)
        continue;

      // XXX: jpa/1173, jpa/1178
      // if (getParentQuery() != null)
      //   break;

      FromItem joinParent = join.getJoinParent();
      FromItem joinTarget = join.getJoinTarget();

      boolean isTarget = item == joinTarget;

      if (joinParent == null) {
      }
      else if (joinParent.getJoinExpr() == null
               && joinParent == joinTarget
               && ! usesFromData(joinParent)) {
        _fromList.remove(joinParent);

        replaceJoin(join);

        // XXX:
        item.setJoinExpr(null);
        //item.setOuterJoin(false);
        i = -1;

        AmberExpr joinWhere = join.getWhere();

        if (joinWhere != null)
          _where = AndExpr.create(_where, joinWhere);
      }
      else if (item == joinTarget
               && ! isJoinParent(item)
               && ! usesFromData(item)) {

        boolean isManyToOne = false;
        boolean isManyToMany = false;

        if (join instanceof ManyToOneJoinExpr) {
          // jpa/0h1c
          isManyToOne = true;

          // jpa/1144
          ManyToOneJoinExpr manyToOneJoinExpr;
          manyToOneJoinExpr = (ManyToOneJoinExpr) join;
          isManyToMany = manyToOneJoinExpr.isManyToMany();
        }

        // ejb/06u0, jpa/1144, jpa/0h1c, jpa/114g
        if (isManyToMany || (isManyToOne && ! item.isInnerJoin())) {
          // ejb/06u0 || isFromInnerJoin(item)))) {

          // Optimization for common children query:
          // SELECT o FROM TestBean o WHERE o.parent.id=?
          // jpa/0h1k
          // jpa/114g as negative exists test

          // jpa/0h1m
          if (i + 1 < _fromList.size()) {
            FromItem subItem = _fromList.get(i + 1);

            JoinExpr nextJoin = subItem.getJoinExpr();

            if (nextJoin != null
                && nextJoin instanceof ManyToOneJoinExpr) {
              continue;
            }
View Full Code Here

    // jpa/114f: reorder from list for left outer join
    for (int i = 1; i < _fromList.size(); i++) {
      item = _fromList.get(i);

      if (item.isOuterJoin()) {
        JoinExpr join = item.getJoinExpr();

        if (join == null)
          continue;

        FromItem parent = join.getJoinParent();

        int index = _fromList.indexOf(parent);

        if (index < 0)
          continue;
View Full Code Here

    // jpa/114f: reorder from list for left outer join
    for (int i = 1; i < _fromList.size(); i++) {
      FromItem item = _fromList.get(i);

      if (item.isOuterJoin()) {
        JoinExpr join = item.getJoinExpr();

        if (join == null)
          continue;

        FromItem parent = join.getJoinParent();

        int index = _fromList.indexOf(parent);

        if (index < 0)
          continue;
View Full Code Here

  public FromItem createDependentFromItem(FromItem parent,
                                          LinkColumns link,
                                          String name)
  {
    for (int i = 0; i < _fromList.size(); i++) {
      JoinExpr join = _fromList.get(i).getJoinExpr();

      if (join != null && join.isDependent(parent, link))
        return _fromList.get(i);
    }

    FromItem item = createFromItem(null, link.getSourceTable(), name);

    JoinExpr join = new ManyToOneJoinExpr(link, item, parent);

    item.setJoinExpr(join);

    return item;
  }
View Full Code Here

      for (int i = components.size() - 1; i >= 0; i--) {
        AmberExpr component = components.get(i);

        if (component instanceof JoinExpr) {
          JoinExpr link = (JoinExpr) component;

          if (link.bindToFromItem()) {
            components.remove(i);
          }
        }
      }

      _where = and.getSingle();
    }

    if (_having instanceof AndExpr) {
      AndExpr and = (AndExpr) _having;

      ArrayList<AmberExpr> components = and.getComponents();

      for (int i = components.size() - 1; i >= 0; i--) {
        AmberExpr component = components.get(i);

        if (component instanceof JoinExpr) {
          JoinExpr link = (JoinExpr) component;

          if (link.bindToFromItem()) {
            components.remove(i);
          }
        }
      }

      _having = and.getSingle();
    }

    // Rolls up unused from items from the left to the right.
    // It's not necessary to roll up the rightmost items because
    // they're only created if they're actually needed
    for (int i = 0; i < _fromList.size(); i++) {
      FromItem item = _fromList.get(i);

      JoinExpr join = item.getJoinExpr();

      if (join == null)
        continue;

      // XXX: jpa/1173, jpa/1178
      // if (getParentQuery() != null)
      //   break;

      FromItem joinParent = join.getJoinParent();
      FromItem joinTarget = join.getJoinTarget();

      boolean isTarget = item == joinTarget;

      if (joinParent == null) {
      }
      else if (joinParent.getJoinExpr() == null
               && joinParent == joinTarget
               && ! usesFromData(joinParent)) {
        _fromList.remove(joinParent);

        replaceJoin(join);

        // XXX:
        item.setJoinExpr(null);
        //item.setOuterJoin(false);
        i = -1;

        AmberExpr joinWhere = join.getWhere();

        if (joinWhere != null)
          _where = AndExpr.create(_where, joinWhere);
      }
      else if (item == joinTarget
               && ! isJoinParent(item)
               && ! usesFromData(item)) {

        boolean isManyToOne = false;
        boolean isManyToMany = false;

        if (join instanceof ManyToOneJoinExpr) {
          // jpa/0h1c
          isManyToOne = true;

          // jpa/1144
          ManyToOneJoinExpr manyToOneJoinExpr;
          manyToOneJoinExpr = (ManyToOneJoinExpr) join;
          isManyToMany = manyToOneJoinExpr.isManyToMany();
        }

        // ejb/06u0, jpa/1144, jpa/0h1c, jpa/114g
        if (isManyToMany || (isManyToOne && ! item.isInnerJoin())) {
          // ejb/06u0 || isFromInnerJoin(item)))) {

          // Optimization for common children query:
          // SELECT o FROM TestBean o WHERE o.parent.id=?
          // jpa/0h1k
          // jpa/114g as negative exists test

          // jpa/0h1m
          if (i + 1 < _fromList.size()) {
            FromItem subItem = _fromList.get(i + 1);

            JoinExpr nextJoin = subItem.getJoinExpr();

            if (nextJoin != null
                && nextJoin instanceof ManyToOneJoinExpr) {
              continue;
            }
View Full Code Here

    // jpa/114f: reorder from list for left outer join
    for (int i = 1; i < _fromList.size(); i++) {
      FromItem item = _fromList.get(i);

      if (item.isOuterJoin()) {
        JoinExpr join = item.getJoinExpr();

        if (join == null)
          continue;

        FromItem parent = join.getJoinParent();

        int index = _fromList.indexOf(parent);

        if (index < 0)
          continue;
View Full Code Here

    // jpa/114f: reorder from list for left outer join
    for (int i = 1; i < _fromList.size(); i++) {
      item = _fromList.get(i);

      if (item.isOuterJoin()) {
        JoinExpr join = item.getJoinExpr();

        if (join == null)
          continue;

        FromItem parent = join.getJoinParent();

        int index = _fromList.indexOf(parent);

        if (index < 0)
          continue;
View Full Code Here

TOP

Related Classes of com.caucho.amber.expr.JoinExpr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.