Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.DbJoin


                    .append(" joins.");

            throw new CayenneRuntimeException(msg.toString());
        }

        DbJoin join = joins.get(0);

        DbAttribute attribute = null;

        if (rel.isToMany()) {
            DbEntity ent = (DbEntity) join.getRelationship().getTargetEntity();
            Collection<DbAttribute> pk = ent.getPrimaryKeys();
            if (pk.size() != 1) {
                StringBuilder msg = new StringBuilder();
                msg
                        .append("DB_NAME expressions can only support ")
                        .append("targets with a single column PK. ")
                        .append("This entity has ")
                        .append(pk.size())
                        .append(" columns in primary key.");

                throw new CayenneRuntimeException(msg.toString());
            }

            attribute = pk.iterator().next();
        }
        else {
            attribute = join.getSource();
        }

        processColumn(attribute);
    }
View Full Code Here


        out.append(" ON (");

        List<DbJoin> joins = relationship.getJoins();
        int len = joins.size();
        for (int i = 0; i < len; i++) {
            DbJoin join = joins.get(i);
            if (i > 0) {
                out.append(" AND ");
            }           
           
            out.append(strategy.quoteString(srcAlias));
            out.append('.');
            out.append(strategy.quoteString(join.getSourceName()));
            out.append(" = ");
            out.append(strategy.quoteString(targetAlias));
            out.append('.');
            out.append(strategy.quoteString(join.getTargetName()));
        }

        out.append(')');

        for (JoinTreeNode child : node.getChildren()) {
View Full Code Here

        }
        else if (joinsLen > 1) {
            // ignore extra joins
        }

        DbJoin join = rel.getJoins().get(0);

        buf
            .append("INSERT INTO _SYS_RELATIONSHIP (")
            .append("dest_table, dest_column, source_table, source_column, ")
            .append("block_delete, cascade_delete, one_to_many, operator, relationshipName")
            .append(") VALUES ('")
            .append(sourceEntity.getFullyQualifiedName())
            .append("', '")
            .append(join.getSourceName())
            .append("', '")
            .append(targetEntity.getFullyQualifiedName())
            .append("', '")
            .append(join.getTargetName())
            .append("', 0, 0, ")
            .append(toMany)
            .append(", '=', '")
            .append(rel.getName())
            .append("')");
View Full Code Here

        String targetAlias = node.getTargetTableAlias();

        List<DbJoin> joins = relationship.getJoins();
        int len = joins.size();
        for (int i = 0; i < len; i++) {
            DbJoin join = joins.get(i);

            if (i > 0) {
                out.append(" AND ");
            }

            out.append(srcAlias).append('.').append(join.getSourceName());

            switch (node.getJoinType()) {
                case INNER:
                    out.append(" = ");
                    break;
                case LEFT_OUTER:
                    out.append(" * ");
                    break;
                default:
                    throw new IllegalArgumentException("Unsupported join type: "
                            + node.getJoinType());
            }

            out.append(targetAlias).append('.').append(join.getTargetName());
        }

        for (JoinTreeNode child : node.getChildren()) {
            out.append(" AND ");
            appendQualifierSubtree(out, child);
View Full Code Here

        String targetAlias = node.getTargetTableAlias();

        List<DbJoin> joins = relationship.getJoins();
        int len = joins.size();
        for (int i = 0; i < len; i++) {
            DbJoin join = joins.get(i);

            if (i > 0) {
                out.append(" AND ");
            }

            out.append(srcAlias).append('.').append(join.getSourceName());

            switch (node.getJoinType()) {
                case INNER:
                    out.append(" = ");
                    break;
                case LEFT_OUTER:
                    out.append(" * ");
                    break;
                default:
                    throw new IllegalArgumentException("Unsupported join type: "
                            + node.getJoinType());
            }

            out.append(targetAlias).append('.').append(join.getTargetName());

        }

        for (JoinTreeNode child : node.getChildren()) {
            out.append(" AND ");
View Full Code Here

            String targetAlias = appendTable(rhsId);
            context.append(" ON (");

            Iterator<DbJoin> it = incomingDB.getJoins().iterator();
            if (it.hasNext()) {
                DbJoin dbJoin = it.next();
                context
                        .append(sourceAlias)
                        .append('.')
                        .append(dbJoin.getSourceName())
                        .append(" = ")
                        .append(targetAlias)
                        .append('.')
                        .append(dbJoin.getTargetName());
            }

            while (it.hasNext()) {
                context.append(", ");
                DbJoin dbJoin = it.next();
                context
                        .append(sourceAlias)
                        .append('.')
                        .append(dbJoin.getSourceName())
                        .append(" = ")
                        .append(targetAlias)
                        .append('.')
                        .append(dbJoin.getTargetName());
            }

            context.append(")");
        }
        finally {
View Full Code Here

                        .get(0);
                Iterator attributePairIterator = firstRel.getJoins().iterator();
                // by default, the relation will be check for mandatory.
                boolean check = true;
                while (attributePairIterator.hasNext()) {
                    DbJoin pair = (DbJoin) attributePairIterator.next();
                    if (!pair.getSource().isMandatory()) {
                        // a field of the fk can be nullable, cancel the check.
                        check = false;
                        break;
                    }
                }
View Full Code Here

        }
        else if (joinsLen > 1) {
            // ignore extra joins
        }

        DbJoin join = rel.getJoins().get(0);

        buf
            .append("INSERT INTO _SYS_RELATIONSHIP (")
            .append("dest_table, dest_column, source_table, source_column, ")
            .append("block_delete, cascade_delete, one_to_many, operator, relationshipName")
            .append(") VALUES ('")
            .append(sourceEntity.getFullyQualifiedName())
            .append("', '")
            .append(join.getSourceName())
            .append("', '")
            .append(targetEntity.getFullyQualifiedName())
            .append("', '")
            .append(join.getTargetName())
            .append("', 0, 0, ")
            .append(toMany)
            .append(", '=', '")
            .append(rel.getName())
            .append("')");
View Full Code Here

        // TODO: andrus, 8/11/2007 flattened?
        DbRelationship correlatedJoinRelationship = context.getIncomingRelationships(
                new EJBQLTableId(id)).get(0);
        Iterator<DbJoin> it = correlatedJoinRelationship.getJoins().iterator();
        while (it.hasNext()) {
            DbJoin join = it.next();
            context.append(' ').append(subqueryRootAlias).append('.').append(
                    join.getTargetName()).append(" = ");
            context.append(correlatedTableAlias).append('.').append(join.getSourceName());

            if (it.hasNext()) {
                context.append(" AND");
            }
        }
View Full Code Here

                    table.getFullyQualifiedName());

            List<DbJoin> joins = dbRelationship.getJoins();

            if (joins.size() == 1) {
                DbJoin join = joins.get(0);
                context.append(' ');
                if (isUsingAliases()) {
                    context.append(alias).append('.');
                }
                context.append(join.getSourceName());
            }
            else {
                Map<String, String> multiColumnMatch = new HashMap<String, String>(joins
                        .size() + 2);

                for (DbJoin join : joins) {
                    String column = isUsingAliases()
                            ? alias + "." + join.getSourceName()
                            : join.getSourceName();

                    multiColumnMatch.put(join.getTargetName(), column);
                }

                appendMultiColumnPath(EJBQLMultiColumnOperand.getPathOperand(
                        context,
                        multiColumnMatch));
View Full Code Here

TOP

Related Classes of org.apache.cayenne.map.DbJoin

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.