Package org.apache.cayenne.map

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 ");
View Full Code Here


                DbEntity source = getEntity();
                DbEntity dest = (DbEntity) rel.getTargetEntity();

                // only use the first. See adapter
                // TODO: can we be sure this is the first and same as used by the adapter?
                DbJoin join = rel.getJoins().get(0);

                // see comment in adapter for why source and dest is switched around..

                buf.append(" source_table = '");
                buf.append(dest.getFullyQualifiedName());
                buf.append("'");

                buf.append(" and source_column = '");
                buf.append(join.getTargetName());
                buf.append("'");

                buf.append(" and dest_table = '");
                buf.append(source.getFullyQualifiedName());
                buf.append("'");

                buf.append(" and dest_column = '");
                buf.append(join.getSourceName());
                buf.append("'");

                return Collections.singletonList(buf.toString());
            }
View Full Code Here

                        .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

        Map<String, Object> snapshot = new HashMap<String, Object>(fromSourceJoins.size()
                + toTargetJoins.size(), 1);

        for (int i = 0, numJoins = fromSourceJoins.size(); i < numJoins; i++) {
            DbJoin join = fromSourceJoins.get(i);

            Object value = new PropagatedValueFactory(sourceId, join.getSourceName());
            snapshot.put(join.getTargetName(), value);
        }

        for (int i = 0, numJoins = toTargetJoins.size(); i < numJoins; i++) {
            DbJoin join = toTargetJoins.get(i);
            Object value = new PropagatedValueFactory(destinationId, join.getTargetName());
            snapshot.put(join.getSourceName(), value);
        }

        return snapshot;
    }
View Full Code Here

                    .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()));
        }
       
        /**
         * Attaching root Db entity's qualifier
         */
 
View Full Code Here

                        logObj.info("no attribute for declared foreign key: " + fkName);
                        continue;
                    }

                    if (forwardRelationship != null) {
                        forwardRelationship.addJoin(new DbJoin(
                                forwardRelationship,
                                pkName,
                                fkName));
                    }
                    if (reverseRelationship != null) {
                        reverseRelationship.addJoin(new DbJoin(
                                reverseRelationship,
                                fkName,
                                pkName));
                    }
View Full Code Here

                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

                    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

                    table.getFullyQualifiedName());

            List<DbJoin> joins = relationship.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.