Package org.apache.ojb.broker.metadata

Examples of org.apache.ojb.broker.metadata.CollectionDescriptor


    }

    void changeActorCollectionDescriptorTo(boolean autoRetrieve, int autoUpdate, int autoDelete, boolean proxy)
    {
        ClassDescriptor cld = broker.getClassDescriptor(Actor.class);
        CollectionDescriptor cod = (CollectionDescriptor) cld.getCollectionDescriptors().get(0);
        cod.setLazy(proxy);
        cod.setCascadeRetrieve(autoRetrieve);
        cod.setCascadingStore(autoUpdate);
        cod.setCascadingDelete(autoDelete);
    }
View Full Code Here


    }

    void changeActorCollectionDescriptorTo(boolean autoRetrieve, boolean autoUpdate, boolean autoDelete, boolean proxy)
    {
        ClassDescriptor cld = broker.getClassDescriptor(Actor.class);
        CollectionDescriptor cod = (CollectionDescriptor) cld.getCollectionDescriptors().get(0);
        cod.setLazy(proxy);
        cod.setCascadeRetrieve(autoRetrieve);
        cod.setCascadeStore(autoUpdate);
        cod.setCascadeDelete(autoDelete);
    }
View Full Code Here

    }

    void changeMovieCollectionDescriptorTo(boolean autoRetrieve, int autoUpdate, int autoDelete, boolean proxy)
    {
        ClassDescriptor cld = broker.getClassDescriptor(MovieImpl.class);
        CollectionDescriptor cod = (CollectionDescriptor) cld.getCollectionDescriptors().get(0);
        cod.setLazy(proxy);
        cod.setCascadeRetrieve(autoRetrieve);
        cod.setCascadingStore(autoUpdate);
        cod.setCascadingDelete(autoDelete);
    }
View Full Code Here

     * Store m-side and intermediary
     */
    public void testStoringWithAutoUpdateFalse1()
    {
        ClassDescriptor cld = broker.getClassDescriptor(Paper.class);
        CollectionDescriptor cod = cld.getCollectionDescriptorByName("qualifiers");
        int autoUpdate = cod.getCascadingStore();

        cod.setCascadingStore(ObjectReferenceDescriptor.CASCADE_LINK);

        try
        {
            String now = new Date().toString();
            Paper paper = new Paper();
            paper.setAuthor("Jonny Myers");
            paper.setDate(now);
            Qualifier qual = new Topic();
            qual.setName("qual " + now);
            paper.setQualifiers(Arrays.asList(new Qualifier[] { qual }));
            broker.beginTransaction();
            broker.store(paper);        // store Paper and intermediary table only
            Identity paperId = new Identity(paper, broker);
            broker.commitTransaction();

            broker.clearCache();
            broker.beginTransaction();
            Paper retPaper = (Paper) broker.getObjectByIdentity(paperId);
            assertEquals(0, retPaper.getQualifiers().size());
            broker.commitTransaction();
        }
        finally
        {
            cod.setCascadingStore(autoUpdate);
        }
    }
View Full Code Here

     * n-side forced by using broker.store()
     */
    public void testStoringWithAutoUpdateFalse2()
    {
        ClassDescriptor cld = broker.getClassDescriptor(Paper.class);
        CollectionDescriptor cod = cld.getCollectionDescriptorByName("qualifiers");
        int autoUpdate = cod.getCascadingStore();

        cod.setCascadingStore(ObjectReferenceDescriptor.CASCADE_LINK);

        try
        {
            String now = new Date().toString();
            Paper paper = new Paper();
            paper.setAuthor("Jonny Myers");
            paper.setDate(now);
            Qualifier qual = new Topic();
            qual.setName("qual " + now);
            paper.setQualifiers(Arrays.asList(new Qualifier[] { qual }));
            broker.beginTransaction();
            broker.store(paper);        // store Paper and intermediary table only
            broker.store(qual);         // store Qualifier
            Identity paperId = new Identity(paper, broker);
            broker.commitTransaction();

            broker.clearCache();
            broker.beginTransaction();
            Paper retPaper = (Paper) broker.getObjectByIdentity(paperId);
            assertEquals(1, retPaper.getQualifiers().size());
            broker.commitTransaction();
        }
        finally
        {
            cod.setCascadingStore(autoUpdate);
        }
    }
View Full Code Here

     * Store m-side, intermediary and n-side
     */
    public void testStoringWithAutoUpdateTrue()
    {
        ClassDescriptor cld = broker.getClassDescriptor(Paper.class);
        CollectionDescriptor cod = cld.getCollectionDescriptorByName("qualifiers");
        int autoUpdate = cod.getCascadingStore();

        cod.setCascadingStore(ObjectReferenceDescriptor.CASCADE_OBJECT);

        try
        {
            String now = new Date().toString();
            Paper paper = new Paper();
            paper.setAuthor("Jonny Myers");
            paper.setDate(now);
            Qualifier qual = new Topic();
            qual.setName("qual " + now);
            paper.setQualifiers(Arrays.asList(new Qualifier[] { qual }));
            broker.beginTransaction();
            broker.store(paper);        // store Paper, intermediary and Qualifier
            Identity paperId = new Identity(paper, broker);
            broker.commitTransaction();

            broker.clearCache();
            broker.beginTransaction();
            Paper retPaper = (Paper) broker.getObjectByIdentity(paperId);
            assertEquals(1, retPaper.getQualifiers().size());
            broker.commitTransaction();
        }
        finally
        {
            cod.setCascadingStore(autoUpdate);
        }
    }
View Full Code Here

            }
        }

        // 1:N relations
        Iterator collections = mif.getCollectionDescriptors().iterator();
        CollectionDescriptor collectionDescriptor;

        while (collections.hasNext())
        {
            collectionDescriptor = (CollectionDescriptor) collections.next();
            field = collectionDescriptor.getPersistentField();
            if (Collection.class.isAssignableFrom(field.getType()))
            {
                Collection newCol;
                Collection oldCol;
View Full Code Here

        if (implicitLocking)
        {
            Iterator i = cld.getCollectionDescriptors().iterator();
            while (i.hasNext())
            {
                CollectionDescriptor cds = (CollectionDescriptor) i.next();
                Object col = cds.getPersistentField().get(sourceObject);
                if (col != null)
                {
                    CollectionProxy proxy = ProxyHelper.getCollectionProxy(col);
                    if (proxy != null)
                    {
                        if (!proxy.isLoaded())
                        {
                            if (log.isDebugEnabled()) log.debug("adding self as listener to collection proxy");
                            proxy.addListener(this);
                            registeredCollectionProxies.add(proxy);
                            continue;
                        }
                    }
                    Iterator colIterator = BrokerHelper.getCollectionIterator(col);
                    Object item = null;
                    try
                    {
                        while (colIterator.hasNext())
                        {
                            item = colIterator.next();
                            RuntimeObject rt = new RuntimeObject(item, this);
                            if (rt.isProxy())
                            {
                                IndirectionHandler handler = ProxyHelper.getIndirectionHandler(item);
                                if (!handler.alreadyMaterialized())
                                {
                                    handler.addListener(this);
                                    continue;
                                }
                                else
                                {
                                    // @todo consider registering to hear when this is
                                    // derefernced instead of just loading here -bmc
                                    item = handler.getRealSubject();
                                }
                            }
                            lockAndRegister(rt, lockMode, true);
                        }
                    }
                    catch (LockNotGrantedException e)
                    {
                        String eol = SystemUtils.LINE_SEPARATOR;
                        log.error("Lock not granted, while lock collection references[" +
                                eol + "current reference descriptor:" +
                                eol + cds.toXML() +
                                eol + "object to lock: " + item +
                                eol + "main object class: " + sourceObject.getClass().getName() +
                                eol + "]", e);
                        throw e;
                    }
View Full Code Here

//        ord.setCascadingDelete(ObjectReferenceDescriptor.CASCADE_NONE);
        if(runtimeSetting == null)
        {
            if(ord instanceof CollectionDescriptor)
            {
                CollectionDescriptor cds = (CollectionDescriptor) ord;
//                if(cds.isMtoNRelation())
//                {
//                    ord.setCascadingStore(ObjectReferenceDescriptor.CASCADE_NONE);
//                    ord.setCascadingDelete(ObjectReferenceDescriptor.CASCADE_NONE);
//                }
                if(cds.isMtoNRelation())
                {
                    result = implementation.cascadingDeleteMtoN;
                }
                else
                {
View Full Code Here

            }
        }

        // 1:N relations
        Iterator collections = mif.getCollectionDescriptors().iterator();
        CollectionDescriptor cds;
        Object userCol;
        Iterator userColIterator;
        Class type;
        ArrayList newUserCol = null;
        ArrayList newCacheCol = null;

        while (collections.hasNext())
        {
            cds = (CollectionDescriptor) collections.next();
            f = cds.getPersistentField();
            type = f.getType();
            isDependent = cds.getOtmDependent();
            if (onlyDependants && !isDependent)
            {
                continue;
            }
            userCol = f.get(userObject);
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.metadata.CollectionDescriptor

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.