Examples of DbRelationship


Examples of org.apache.cayenne.map.DbRelationship

                                "No matching objects found for ObjectId "
                                        + object.getObjectId()
                                        + ". Object may have been deleted externally.");
                    }

                    DbRelationship dbRel = rel.getDbRelationships().get(0);
                    for (DbJoin join : dbRel.getJoins()) {
                        String key = join.getSourceName();
                        snapshot.put(key, storedSnapshot.get(key));
                    }

                    return true;
                }

                // target is resolved and we have an FK->PK to it,
                // so extract it from target...
                Persistent target = (Persistent) targetObject;
                Map<String, Object> idParts = target.getObjectId().getIdSnapshot();

                // this may happen in uncommitted objects - see the warning in the JavaDoc
                // of
                // this method.
                if (idParts.isEmpty()) {
                    return true;
                }

                DbRelationship dbRel = rel.getDbRelationships().get(0);
                Map<String, Object> fk = dbRel.srcFkSnapshotWithTargetSnapshot(idParts);
                snapshot.putAll(fk);
                return true;
            }
        });
View Full Code Here

Examples of org.apache.cayenne.map.DbRelationship

                        .getEntityDescriptor(id.getEntityId())
                        .getEntity()
                        .getDbEntity();
            }
            else {
                DbRelationship last = incoming.get(incoming.size() - 1);
                entity = (DbEntity) last.getTargetEntity();
            }

            incoming = new ArrayList<DbRelationship>(incoming);

            Iterator<?> it = entity.resolvePathComponents(id.getDbPath());
View Full Code Here

Examples of org.apache.cayenne.map.DbRelationship

        if (joinRelationships.isEmpty()) {
            throw new EJBQLException("No join configured for id " + rhsId);
        }

        // TODO: andrus, 4/8/2007 - support for flattened relationships
        DbRelationship incomingDB = joinRelationships.get(0);

        // TODO: andrus, 1/6/2008 - move reusable join check here...

        String sourceAlias = context.getTableAlias(lhsId.getEntityId(), incomingDB
                .getSourceEntity()
                .getName());

        if (marker != null) {
            context.pushMarker(marker, false);
        }

        try {

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

            Iterator<DbJoin> it = incomingDB.getJoins().iterator();
            if (it.hasNext()) {
                DbJoin dbJoin = it.next();
                context
                        .append(sourceAlias)
                        .append('.')
View Full Code Here

Examples of org.apache.cayenne.map.DbRelationship

        // support "AS", and the rest of the databases do not care
        context.append(subqueryTableName).append(' ').append(subqueryRootAlias);
        context.append(" WHERE");

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

Examples of org.apache.cayenne.map.DbRelationship

        // support "AS", and the rest of the databases do not care
        context.append(subqueryTableName).append(' ').append(subqueryRootAlias);
        context.append(" WHERE");

        // TODO: andrus, 8/11/2007 flattened?
        DbRelationship correlatedJoinRelationship = context.getIncomingRelationships(
                new EJBQLTableId(id)).get(0);

        for (DbJoin join : correlatedJoinRelationship.getJoins()) {
            context.append(' ').append(subqueryRootAlias).append('.').append(
                    join.getTargetName()).append(" = ");
            context.append(correlatedTableAlias).append('.').append(join.getSourceName());
            context.append(" AND");
        }
View Full Code Here

Examples of org.apache.cayenne.map.DbRelationship

                            joinAppender = context
                                    .getTranslatorFactory()
                                    .getJoinAppender(context);
                        }

                        DbRelationship dr = (DbRelationship) pathPart;

                        EJBQLTableId rhsId = new EJBQLTableId(lhsId, dr.getName());
                        joinAppender.appendOuterJoin(marker, lhsId, rhsId);
                        lhsId = rhsId;
                    }
                    else if (pathPart instanceof DbAttribute) {
                        appendColumn(idVar, oa, (DbAttribute) pathPart, fields, oa
                                .getType());
                    }
                }
                return true;
            }

            public boolean visitToMany(ToManyProperty property) {
                visitRelationship(property);
                return true;
            }

            public boolean visitToOne(ToOneProperty property) {
                visitRelationship(property);
                return true;
            }

            private void visitRelationship(ArcProperty property) {
                ObjRelationship rel = property.getRelationship();
                DbRelationship dbRel = rel.getDbRelationships().get(0);

                for (DbJoin join : dbRel.getJoins()) {
                    DbAttribute src = join.getSource();
                    appendColumn(idVar, null, src, fields);
                }
            }
        };
View Full Code Here

Examples of org.apache.cayenne.map.DbRelationship

            context.append(subqueryTableName).append(' ').append(subqueryRootAlias);

        }
        context.append(" WHERE");

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

Examples of org.apache.cayenne.map.DbRelationship

        }

        context.append(" WHERE");

        DbRelationship correlatedJoinRelationship = context.getIncomingRelationships(
                new EJBQLTableId(id)).get(0);

        for (DbJoin join : correlatedJoinRelationship.getJoins()) {
            context.append(' ').append(subqueryRootAlias).append('.').append(
                    join.getTargetName()).append(" = ");
            context.append(correlatedTableAlias).append('.').append(join.getSourceName());
            context.append(" AND");
        }
View Full Code Here

Examples of org.apache.cayenne.map.DbRelationship

        // impl.
        matchingObject = false;

        boolean first = true;

        DbRelationship relationship = objectMatchTranslator.getRelationship();
        if (!relationship.isToMany() && !relationship.isToPK()) {
            queryAssembler.dbRelationshipAdded(
                    relationship,
                    JoinType.INNER,
                    objectMatchTranslator.getJoinSplitAlias());
        }
View Full Code Here

Examples of org.apache.cayenne.map.DbRelationship

            String subqueryRootAlias,
            ObjRelationship relationship) {
        List<DbRelationship> dbRelationships = relationship.getDbRelationships();
        // reverse order to get the nearest to the correlated of the direct relation
        for (int i = dbRelationships.size() - 1; i > 0; i--) {
            DbRelationship dbRelationship = dbRelationships.get(i);
            String subqueryTargetTableName = ((DbEntity) dbRelationship.getTargetEntity())
                    .getFullyQualifiedName();
            String subqueryTargetAlias;
            if (i == dbRelationships.size() - 1) {
                subqueryTargetAlias = subqueryRootAlias;
                context.append(subqueryTargetTableName).append(' ').append(
                        subqueryTargetAlias);
            }
            else {
                subqueryTargetAlias = context.getTableAlias(
                        subqueryTargetTableName,
                        subqueryTargetTableName);
            }

            context.append(" JOIN ");

            String subquerySourceTableName = ((DbEntity) dbRelationship.getSourceEntity())
                    .getFullyQualifiedName();
            String subquerySourceAlias = context.getTableAlias(
                    subquerySourceTableName,
                    subquerySourceTableName);

            context.append(subquerySourceTableName).append(' ').append(
                    subquerySourceAlias);

            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(" = ");
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.