Examples of DbJoin


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

Examples of org.apache.cayenne.map.DbJoin

                    List joins = (List) relMap.get("joins");
                    Iterator jIt = joins.iterator();
                    while (jIt.hasNext()) {
                        Map joinMap = (Map) jIt.next();

                        DbJoin join = new DbJoin(dbRel);

                        // find source attribute dictionary and extract the column name
                        String sourceAttributeName = (String) joinMap
                                .get("sourceAttribute");
                        join.setSourceName(columnName(attributes, sourceAttributeName));

                        String targetAttributeName = (String) joinMap
                                .get("destinationAttribute");

                        join.setTargetName(columnName(
                                targetAttributes,
                                targetAttributeName));
                        dbRel.addJoin(join);
                    }
                }
View Full Code Here

Examples of org.apache.cayenne.map.DbJoin

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

Examples of org.apache.cayenne.map.DbJoin

                DbRelationship dbRel = rel.getDbRelationships().get(0);

                List<DbJoin> joins = dbRel.getJoins();
                int len = joins.size();
                for (int i = 0; i < len; i++) {
                    DbJoin join = joins.get(i);
                    DbAttribute src = join.getSource();
                    appendColumn(columns, null, src, attributes, null);
                }
            }
        };
View Full Code Here

Examples of org.apache.cayenne.map.DbJoin

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

Examples of org.apache.cayenne.map.DbJoin

        }
        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

Examples of org.apache.cayenne.map.DbJoin

        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

Examples of org.apache.cayenne.map.DbJoin

            context.append(" ON (");

            List<DbJoin> joins = dbRelationship.getJoins();
            Iterator<DbJoin> it = joins.iterator();
            while (it.hasNext()) {
                DbJoin join = it.next();
                context.append(' ').append(subqueryTargetAlias).append('.').append(
                        join.getTargetName()).append(" = ");
                context.append(subquerySourceAlias).append('.').append(
                        join.getSourceName());
                if (it.hasNext()) {
                    context.append(" AND");
                }
            }
            context.append(" )");
View Full Code Here

Examples of org.apache.cayenne.map.DbJoin

        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

Examples of org.apache.cayenne.map.DbJoin

        }
        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
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.