Examples of ObjRelationship


Examples of org.apache.cayenne.map.ObjRelationship

        if (entity == null) {
            throw new IllegalStateException("DataObject's entity is unmapped, objectId: "
                    + objectId);
        }

        ObjRelationship rel = (ObjRelationship) entity.getRelationship(relName);
        ObjRelationship revRel = rel.getReverseRelationship();
        if (revRel != null) {
            if (revRel.isToMany())
                val.removeToManyTarget(revRel.getName(), this, false);
            else
                val.setToOneTarget(revRel.getName(), null, false);
        }
    }
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

        // only include this entity relationships and skip superclasses...
        for (Relationship relationship : descriptor
                .getEntity()
                .getDeclaredRelationships()) {

            ObjRelationship objRelationship = (ObjRelationship) relationship;

            if (relationship.isToMany()) {

                String collectionType = objRelationship.getCollectionType();
                if (collectionType == null
                        || ObjRelationship.DEFAULT_COLLECTION_TYPE.equals(collectionType)) {
                    createToManyListProperty(descriptor, objRelationship);
                }
                else if (collectionType.equals("java.util.Map")) {
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

        context.deleteObjects(paintings);

        // as Painting -> Artist has Nullify rule, relationship list has to be cleaned up,
        // and no exceptions thrown on concurrent modification...
        ObjRelationship r = (ObjRelationship) context
                .getEntityResolver()
                .lookupObjEntity(Painting.class)
                .getRelationship("toArtist");
        assertEquals(DeleteRule.NULLIFY, r.getDeleteRule());
        assertEquals(0, paintings.size());

        it = paintingsClone.iterator();
        while (it.hasNext()) {
            DataObject object = (DataObject) it.next();
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

        // find last relationship
        Iterator<CayenneMapEntry> it = classDescriptor.getEntity().resolvePathComponents(
                prefetchPath);

        ObjRelationship relationship = null;
        while (it.hasNext()) {
            relationship = (ObjRelationship) it.next();
        }

        if (relationship == null) {
            throw new CayenneRuntimeException(
                    "Invalid prefetch '%s' for entity '%s'",
                    prefetchPath,
                    classDescriptor.getEntity().getName());
        }

        // chain query and entity qualifiers
        Expression queryQualifier = query.getQualifier();

        Expression entityQualifier = classDescriptor
                .getEntityInheritanceTree()
                .qualifierForEntityAndSubclasses();

        if (entityQualifier != null) {
            queryQualifier = (queryQualifier != null) ? queryQualifier
                    .andExp(entityQualifier) : entityQualifier;
        }

        // create and configure PrefetchSelectQuery
        PrefetchSelectQuery prefetchQuery = new PrefetchSelectQuery(
                query,
                prefetchPath,
                relationship);

        prefetchQuery.setQualifier(classDescriptor.getEntity().translateToRelatedEntity(
                queryQualifier,
                prefetchPath));

        if (relationship.isSourceIndependentFromTargetChange()) {
            // setup extra result columns to be able to relate result rows to the parent
            // result objects.
            prefetchQuery.addResultPath("db:"
                    + relationship.getReverseDbRelationshipPath());
        }

        // pass prefetch subtree to enable joint prefetches...
        prefetchQuery.setPrefetchTree(node);
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

                idProperties.add(attributeProperty);
            }
        }
        else if (property instanceof ArcProperty) {
            ObjRelationship relationship = ((ArcProperty) property).getRelationship();
            ObjRelationship reverseRelationship = relationship.getReverseRelationship();
            if (reverseRelationship != null
                    && "java.util.Map".equals(reverseRelationship.getCollectionType())) {

                if (mapArcProperties == null) {
                    mapArcProperties = new ArrayList<ArcProperty>(2);
                }
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

        List<DbRelationship> reflexiveRels = reflexiveDbEntities.get(dbEntity);
        String[] reflexiveRelNames = new String[reflexiveRels.size()];
        for (int i = 0; i < reflexiveRelNames.length; i++) {
            DbRelationship dbRel = reflexiveRels.get(i);
            ObjRelationship objRel = (dbRel != null ? objEntity
                    .getRelationshipForDbRelationship(dbRel) : null);
            reflexiveRelNames[i] = (objRel != null ? objRel.getName() : null);
        }

        List<Persistent> sorted = new ArrayList<Persistent>(size);

        Digraph<Persistent, Boolean> objectDependencyGraph = new MapDigraph<Persistent, Boolean>();
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

    }

    public void testNoActionFlattenedNoReverse() {
        // temporarily set delete rule to NOACTION...
        int oldRule = changeDeleteRule(DeleteRule.NO_ACTION);
        ObjRelationship reverse = unsetReverse();

        try {
            DeleteRuleFlatA a = context.newObject(DeleteRuleFlatA.class);
            DeleteRuleFlatB b = context.newObject(DeleteRuleFlatB.class);
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

    }

    public void testCascadeFlattenedNoReverse() {
        // temporarily set delete rule to CASCADE...
        int oldRule = changeDeleteRule(DeleteRule.CASCADE);
        ObjRelationship reverse = unsetReverse();

        try {
            DeleteRuleFlatA a = context.newObject(DeleteRuleFlatA.class);
            DeleteRuleFlatB b = context.newObject(DeleteRuleFlatB.class);
            a.addToFlatB(b);
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

    }

    public void testNullifyFlattenedNoReverse() {
        // temporarily set delete rule to NULLIFY...
        int oldRule = changeDeleteRule(DeleteRule.NULLIFY);
        ObjRelationship reverse = unsetReverse();

        try {
            DeleteRuleFlatA a = context.newObject(DeleteRuleFlatA.class);
            DeleteRuleFlatB b = context.newObject(DeleteRuleFlatB.class);
            a.addToFlatB(b);
View Full Code Here

Examples of org.apache.cayenne.map.ObjRelationship

    }

    public void testDenyFlattenedNoReverse() {
        // temporarily set delete rule to DENY...
        int oldRule = changeDeleteRule(DeleteRule.DENY);
        ObjRelationship reverse = unsetReverse();

        try {
            DeleteRuleFlatA a = context.newObject(DeleteRuleFlatA.class);
            DeleteRuleFlatB b = context.newObject(DeleteRuleFlatB.class);
            a.addToFlatB(b);
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.