Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.Proxy


    public void load(final OpenJPAStateManager sm, final JDBCStore store,
        final JDBCFetchConfiguration fetch)
        throws SQLException {
        if (field.isLRS()) {
            Proxy coll = newLRSProxy();

            // if this is ordered we need to know the next seq to use in case
            // objects are added to the collection
            if (field.getOrderColumn() != null) {
                // we don't allow ordering table per class one-many's, so
                // we know we don't need a union
                Select sel = store.getSQLFactory().newSelect();
                sel.setAggregate(true);
                StringBuffer sql = new StringBuffer();
                sql.append("MAX(").
                    append(sel.getColumnAlias(field.getOrderColumn())).
                    append(")");
                sel.select(sql.toString(), field);
                ClassMapping rel = getDefaultElementMapping(false);
                sel.whereForeignKey(getJoinForeignKey(rel),
                    sm.getObjectId(), field.getDefiningMapping(), store);

                Result res = sel.execute(store, fetch);
                try {
                    res.next();
                    coll.getChangeTracker().setNextSequence
                        (res.getInt(field) + 1);
                } finally {
                    res.close();
                }
            }
View Full Code Here


            return;

        Object obj = sm.fetchObject(field.getIndex());
        ChangeTracker ct = null;
        if (obj instanceof Proxy) {
            Proxy proxy = (Proxy) obj;
            if (Proxies.isOwner(proxy, sm, field.getIndex()))
                ct = proxy.getChangeTracker();
        }

        // if no fine-grained change tracking then just delete and reinsert
        if (ct == null || !ct.isTracking()) {
            delete(sm, store, rm);
View Full Code Here

                return;
            }
        }
       
        if (field.isLRS()) {
            Proxy pcoll = newLRSProxy();

            // if this is ordered we need to know the next seq to use in case
            // objects are added to the collection
            if (field.getOrderColumn() != null) {
                // we don't allow ordering table per class one-many's, so
                // we know we don't need a union
                Select sel = store.getSQLFactory().newSelect();
                sel.setAggregate(true);
                StringBuilder sql = new StringBuilder();
                sql.append("MAX(").
                    append(sel.getColumnAlias(field.getOrderColumn())).
                    append(")");
                sel.select(sql.toString(), field);
                ClassMapping rel = getDefaultElementMapping(false);
                sel.whereForeignKey(getJoinForeignKey(rel),
                    sm.getObjectId(), field.getDefiningMapping(), store);

                Result res = sel.execute(store, fetch);
                try {
                    res.next();
                    pcoll.getChangeTracker().setNextSequence
                        (res.getInt(field) + 1);
                } finally {
                    res.close();
                }
            }
View Full Code Here

        assertNotNull(proxy.getDeclaredMethod("removeElementAt", new Class[] { int.class }));
        assertNotNull(proxy.getDeclaredMethod("setElementAt", new Class[] { Object.class, int.class }));
    }

    public void testListChangeTracker() {
        Proxy coll = _mgr.newCollectionProxy(ArrayList.class, null, null, true);
        assertNotNull(coll);
        assertNotNull(coll.getChangeTracker());
        assertTrue(coll.getChangeTracker() instanceof CollectionChangeTrackerImpl);
        CollectionChangeTrackerImpl ct = (CollectionChangeTrackerImpl) coll.getChangeTracker();
        assertTrue(ct.allowsDuplicates());
        assertTrue(ct.isOrdered());
    }
View Full Code Here

        assertTrue(ct.allowsDuplicates());
        assertTrue(ct.isOrdered());
    }

    public void testSetChangeTracker() {
        Proxy coll = _mgr.newCollectionProxy(HashSet.class, null, null, true);
        assertNotNull(coll);
        assertNotNull(coll.getChangeTracker());
        assertTrue(coll.getChangeTracker() instanceof CollectionChangeTrackerImpl);
        CollectionChangeTrackerImpl ct = (CollectionChangeTrackerImpl) coll.getChangeTracker();
        assertFalse(ct.allowsDuplicates());
        assertFalse(ct.isOrdered());
    }
View Full Code Here

        assertFalse(ct.allowsDuplicates());
        assertFalse(ct.isOrdered());
    }

    public void testCollectionInterfaceProxy() {
        Proxy coll = _mgr.newCollectionProxy(Collection.class, null, null, true);
        assertNotNull(coll);
    }
View Full Code Here

        Proxy coll = _mgr.newCollectionProxy(Collection.class, null, null, true);
        assertNotNull(coll);
    }

    public void testListInterfaceProxy() {
        Proxy coll = _mgr.newCollectionProxy(List.class, null, null, true);
        assertNotNull(coll);
        assertTrue(coll instanceof List);
    }
View Full Code Here

        assertNotNull(coll);
        assertTrue(coll instanceof List);
    }

    public void testSetInterfaceProxy() {
        Proxy coll = _mgr.newCollectionProxy(Set.class, null, null, true);
        assertNotNull(coll);
        assertTrue(coll instanceof Set);
        assertFalse(coll instanceof SortedSet);
    }
View Full Code Here

        assertTrue(coll instanceof Set);
        assertFalse(coll instanceof SortedSet);
    }

    public void testSortedSetInterfaceProxy() {
        Proxy coll = _mgr.newCollectionProxy(SortedSet.class, null, null, true);
        assertNotNull(coll);
        assertTrue(coll instanceof SortedSet);
    }
View Full Code Here

    public void testQueueInterfaceProxy() {
        Class queue = getQueueClass();
        if (queue == null)
            return;

        Proxy coll = _mgr.newCollectionProxy(queue, null, null, true);
        assertNotNull(coll);
        assertTrue(queue.isInstance(coll));
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.util.Proxy

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.