Package com.caucho.amber.table

Examples of com.caucho.amber.table.LinkColumns


                         joinColumnsConfig);

    eltCollectionField.setAssociationTable(mapTable);
    eltCollectionField.setTable(sqlTable);

    eltCollectionField.setSourceLink(new LinkColumns(mapTable,
                                                     _sourceType.getTable(),
                                                     sourceColumns));
   
    _sourceType.addField(eltCollectionField);
  }
View Full Code Here


    if (type.getSecondaryTables().size() > 0) {
      for (AmberField field : type.getFields()) {
        AmberTable subTable = field.getTable();

        if (subTable != null && subTable != type.getTable()) {
          LinkColumns link = subTable.getDependentIdLink();

          FromItem item = parser.createDependentFromItem(_fromItem, link);

          _subItems.add(item);
        }
View Full Code Here

      oneToMany = (OneToManyExpr) _collectionExpr;
    }
    else
      throw new UnsupportedOperationException();

    LinkColumns join = oneToMany.getLinkColumns();

    if (_isNot)
      cb.append("NOT ");

    // jpa/10ca
    // XXX: needs to handle compound PK.
    ForeignColumn fk = (ForeignColumn) join.getColumns().get(0);
    cb.append(oneToMany.getParent().getChildFromItem().getName());
    cb.append('.');
    cb.append(fk.getTargetColumn().getName());

    // changed to IN for jpa/10ca cb.append("EXISTS (SELECT *");
    cb.append(" IN (SELECT "); // SELECT *");
    cb.append(fk.getName());
    AmberTable table = join.getSourceTable();
    cb.append(" FROM " + table.getName() + " caucho");
    cb.append(" WHERE ");

    String targetTable = oneToMany.getParent().getChildFromItem().getName();

    cb.append(join.generateJoin("caucho", targetTable));

    if (_itemExpr instanceof ArgExpr) {

      cb.append(" AND caucho.");

      if (_collectionExpr instanceof ManyToOneExpr) {
        join = ((ManyToOneExpr) _collectionExpr).getLinkColumns();

        String name = join.getColumns().get(0).getName();

        cb.append(name);
      }
      else {
        // XXX: needs to handle compound PK.
        ArrayList<AmberColumn> idColumns =
          join.getSourceTable().getIdColumns();

        cb.append(idColumns.get(0).getName());
      }

      cb.append(" = ?");
    }
    else if (_collectionExpr instanceof ManyToOneExpr) {
      join = ((ManyToOneExpr) _collectionExpr).getLinkColumns();

      String itemWhere;
      boolean isArg = false;

      String where;

      if (_itemExpr instanceof ManyToOneExpr) {
        LinkColumns manyToOneJoin = ((ManyToOneExpr) _itemExpr).getLinkColumns();

        itemWhere = ((ManyToOneExpr) _itemExpr).getParent().getChildFromItem().getName();

        where = join.generateJoin(manyToOneJoin, "caucho", itemWhere);
      }
View Full Code Here

      OneToManyExpr oneToMany = (OneToManyExpr) arg;

      _groupList = new ArrayList<AmberExpr>();

      LinkColumns linkColumns = oneToMany.getLinkColumns();
      ForeignColumn fkColumn = linkColumns.getColumns().get(0);

      AmberExpr groupExpr = oneToMany.getParent();

      if (groupExpr instanceof PathExpr) {
        // jpa/119n
View Full Code Here

      oneToMany = (OneToManyExpr) _collectionExpr;
    }
    else
      throw new UnsupportedOperationException();

    LinkColumns join = oneToMany.getLinkColumns();

    AmberTable table = join.getSourceTable();
    cb.append("EXISTS(SELECT ");

    if (table.getIdColumns().size() > 0)
      cb.append(table.getIdColumns().get(0).getName());
    else
      cb.append('*');

    cb.append(" FROM " + table.getName() + " " + _tableName);
    cb.append(" WHERE ");

    String targetTable = oneToMany.getParent().getChildFromItem().getName();

    cb.append(join.generateJoin(_tableName, targetTable));

    cb.append(')');
  }
View Full Code Here

      _fromItem = parentFromItem;

      return this;
    }

    LinkColumns link = getColumn().getTable().getDependentIdLink();

    if (link == null)
      return this;

    _fromItem = parser.createDependentFromItem(parentFromItem, link);
View Full Code Here

      _fromItem = parentFromItem;

      return this;
    }

    LinkColumns link = getColumn().getTable().getDependentIdLink();
    _fromItem = parser.createDependentFromItem(parentFromItem, link);

    return this;
  }
View Full Code Here

    manyToManyField.setAssociationTable(mapTable);
    manyToManyField.setTable(sqlTable);
    manyToManyField.setLazy(isFetchLazy());

    manyToManyField.setSourceLink(new LinkColumns(mapTable,
                                                  _sourceType.getTable(),
                                                  sourceColumns));

    manyToManyField.setTargetLink(new LinkColumns(mapTable,
                                                  targetType.getTable(),
                                                  targetColumns));

    _sourceType.addField(manyToManyField);
  }
View Full Code Here

    // jpa/0i5-
    // Update column names for bidirectional many-to-many

    if (! sourceField.hasJoinColumns()) {
      LinkColumns sourceLink = sourceField.getSourceLink();
      ArrayList<ForeignColumn> columns = sourceLink.getColumns();
      for (ForeignColumn column : columns) {
        String columnName = column.getName();
        columnName = columnName.substring(columnName.indexOf('_'));
        columnName = toSqlName(manyToManyField.getName()) + columnName;
        column.setName(columnName);
      }
    }

    if (! sourceField.hasInverseJoinColumns()) {
      LinkColumns targetLink = sourceField.getTargetLink();
      ArrayList<ForeignColumn> columns = targetLink.getColumns();
      for (ForeignColumn column : columns) {
        String columnName = column.getName();
        columnName = columnName.substring(columnName.indexOf('_'));
        columnName = toSqlName(sourceField.getName()) + columnName;
        column.setName(columnName);
View Full Code Here

        from = from + ", " + subTable.getName() + " o" + i;
      else
        from = subTable.getName() + " o" + i;

      if (where != null) {
        LinkColumns link = subTable.getDependentIdLink();

        where = where + " and " + link.generateJoin("o" + i, "o");
      }
      else
        throw new IllegalStateException();
    }
View Full Code Here

TOP

Related Classes of com.caucho.amber.table.LinkColumns

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.