Examples of FromItem


Examples of com.caucho.amber.query.FromItem

  {
    if (_fromItem == from)
      return true;

    for (int i = 0; i < _subItems.size(); i++) {
      FromItem subItem = _subItems.get(i);

      if (from == subItem)
        return true;
    }
View Full Code Here

Examples of com.caucho.amber.query.FromItem

    }

    if (! fullSelect)
      return;

    FromItem item = _fromItem;

    // jpa/0l4b
    if (_rootItem != null) {
      EntityType parentType = (EntityType) type;

      while (parentType.getParentType() != null
             && parentType.getParentType() instanceof EntityType) {
        parentType = parentType.getParentType();
      }

      item = _rootItem;
    }

    String valueSelect = "";

    // jpa/0l12, jpa/0l47
    valueSelect = type.generateLoadSelect(item.getTable(),
                                          item.getName());

    if (valueSelect != null && ! "".equals(valueSelect)) {
      cb.append(", ");
      cb.append(valueSelect);
    }

    for (int i = 0; i < _subItems.size(); i++) {
      item = _subItems.get(i);

      valueSelect = type.generateLoadSelect(item.getTable(), item.getName());

      if (! valueSelect.equals("")) {
        cb.append(", ");
        cb.append(valueSelect);
      }
View Full Code Here

Examples of com.caucho.amber.query.FromItem

  public FromItem addFromItem(QueryParser parser, String id)
    throws QueryParseException
  {
    _expr.bindSelect(parser, id);

    FromItem fromItem = _expr.getChildFromItem();

    return fromItem;
  }
View Full Code Here

Examples of com.caucho.amber.query.FromItem

    if (_parent instanceof ManyToOneExpr) {
      // jpa/0h1c
      return false;
    }

    FromItem fromItem = _parent.getChildFromItem();

    // ejb/0j00 vs ejb/0h13 vs ejb/0t00
    if (type == IS_INNER_JOIN)
      return (from == fromItem);
    else
View Full Code Here

Examples of com.caucho.amber.query.FromItem

   */
  public FromItem addFromItem(QueryParser parser, String id)
    throws QueryParseException
  {
    // jpa/0l12
    FromItem fromItem = parser.addFromItem(getEntityType(),
                                           getEntityType().getTable(),
                                           id);

    return fromItem;
  }
View Full Code Here

Examples of com.caucho.amber.query.FromItem

  /**
   * Binds the expression as a select item.
   */
  public AmberExpr bindSelect(QueryParser parser)
  {
    FromItem parentFromItem = _parent.bindSubPath(parser);

    if (parentFromItem.getTable() == getColumn().getTable()) {
      _fromItem = parentFromItem;

      return this;
    }

View Full Code Here

Examples of net.sf.jsqlparser.statement.select.FromItem

      buffer.append("JOIN ");

    }
   
    FromItem fromItem = join.getRightItem();
    fromItem.accept(this);
    if (join.getOnExpression() != null) {
      buffer.append(" ON ");
      join.getOnExpression().accept(expressionVisitor);
    }
    if (join.getUsingColumns() != null) {
View Full Code Here

Examples of org.apache.metamodel.query.FromItem

        // check certain common query types that can often be optimized by
        // subclasses
        if (fromItems.size() == 1 && groupByItems.isEmpty() && havingItems.isEmpty()) {

            final FromItem fromItem = query.getFromClause().getItem(0);
            final Table table = fromItem.getTable();
            if (table != null) {
                // check for approximate SELECT COUNT(*) queries
                if (selectItems.size() == 1) {
                    final SelectItem selectItem = query.getSelectClause().getItem(0);
                    if (SelectItem.isCountAllItem(selectItem)) {
                        final boolean functionApproximationAllowed = selectItem.isFunctionApproximationAllowed();
                        if (isMainSchemaTable(table)) {
                            logger.debug("Query is a COUNT query with {} where items. Trying executeCountQuery(...)",
                                    whereItems.size());
                            final Number count = executeCountQuery(table, whereItems, functionApproximationAllowed);
                            if (count == null) {
                                logger.debug("DataContext did not return any count query results. Proceeding with manual counting.");
                            } else {
                                List<Row> data = new ArrayList<Row>(1);
                                final DataSetHeader header = new SimpleDataSetHeader(new SelectItem[] { selectItem });
                                data.add(new DefaultRow(header, new Object[] { count }));
                                return new InMemoryDataSet(header, data);
                            }
                        }
                    }
                }

                // check for lookup query by primary key
                if (whereItems.size() == 1) {
                    final FilterItem whereItem = whereItems.get(0);
                    final SelectItem selectItem = whereItem.getSelectItem();
                    if (!whereItem.isCompoundFilter() && selectItem != null && selectItem.getColumn() != null) {
                        final Column column = selectItem.getColumn();
                        if (column.isPrimaryKey() && whereItem.getOperator() == OperatorType.EQUALS_TO) {
                            logger.debug("Query is a primary key lookup query. Trying executePrimaryKeyLookupQuery(...)");
                            if (table != null) {
                                if (isMainSchemaTable(table)) {
                                    final Object operand = whereItem.getOperand();
                                    final Row row = executePrimaryKeyLookupQuery(table, selectItems, column, operand);
                                    if (row == null) {
                                        logger.debug("DataContext did not return any GET query results. Proceeding with manual lookup.");
                                    } else {
                                        final DataSetHeader header = new SimpleDataSetHeader(selectItems);
                                        return new InMemoryDataSet(header, row);
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }

        final int firstRow = (query.getFirstRow() == null ? 1 : query.getFirstRow());
        final int maxRows = (query.getMaxRows() == null ? -1 : query.getMaxRows());

        // Check for very simple queries with max rows property set (typically
        // preview), see Ticket #187
        previewTable: if (whereItems.isEmpty() && groupByItems.isEmpty() && havingItems.isEmpty()
                && orderByItems.isEmpty() && fromItems.size() == 1) {

            final Table table = fromItems.get(0).getTable();
            if (table != null) {
                for (SelectItem item : selectItems) {
                    if (item.getFunction() != null || item.getExpression() != null) {
                        break previewTable;
                    }
                }

                DataSet dataSet = materializeTable(table, selectItems, firstRow, maxRows);
                dataSet = MetaModelHelper.getSelection(selectItems, dataSet);
                return dataSet;
            }
        }

        // Creates a list for all select items that are needed to execute query
        // (some may only be used as part of a filter, but not shown in result)
        List<SelectItem> workSelectItems = CollectionUtils.concat(true, selectItems, whereSelectItems,
                groupBySelectItems, havingSelectItems, orderBySelectItems);

        // Materialize the tables in the from clause
        final DataSet[] fromDataSets = new DataSet[fromItems.size()];
        for (int i = 0; i < fromDataSets.length; i++) {
            FromItem fromItem = fromItems.get(i);
            fromDataSets[i] = materializeFromItem(fromItem, workSelectItems);
        }

        // Execute the query using the raw data
        DataSet dataSet = MetaModelHelper.getCarthesianProduct(fromDataSets, whereItems);
View Full Code Here

Examples of org.apache.metamodel.query.FromItem

            // We need to materialize a single table
            final Table table = fromItem.getTable();
            final List<SelectItem> selectItemsToMaterialize = new ArrayList<SelectItem>();

            for (final SelectItem selectItem : selectItems) {
                final FromItem selectedFromItem = selectItem.getFromItem();
                if (selectedFromItem != null) {
                    if (selectedFromItem.equals(fromItem)) {
                        selectItemsToMaterialize.add(selectItem.replaceFunction(null));
                    }
                } else {
                    // the select item does not specify a specific
                    // from-item
View Full Code Here

Examples of org.apache.metamodel.query.FromItem

        // Make a new query that joins the normalized tables together
        table = schema.getTableByName("contributors_person_address");
        Relationship relationShip = table.getRelationships()[0];
        q = new Query().select(relationShip.getPrimaryTable().getColumns())
                .select(relationShip.getForeignTable().getColumns()).from(new FromItem(JoinType.INNER, relationShip));

        assertEquals(
                "SELECT contributors_person.id, contributors_person_address.id, "
                        + "contributors_person_address.contributors_person_id, contributors_person_address.address "
                        + "FROM xml_input_eobjects.xml.contributors_person INNER JOIN xml_input_eobjects.xml.contributors_person_address "
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.