Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.Id


        return val;
    }

    public Object getJoinValue(OpenJPAStateManager sm, Column col,
        JDBCStore store) {
        Id id = (Id) sm.getObjectId();
        return (id == null) ? null : id.getIdObject();
    }
View Full Code Here


    public Class<?> getDataStoreIdType(ClassMetaData meta) {
        return Id.class;
    }

    public Object copyDataStoreId(Object oid, ClassMetaData meta) {
        Id id = (Id) oid;
        return new Id(meta.getDescribedType(), id.getId(),
            id.hasSubclasses());
    }
View Full Code Here

            return new ObjectId(cls, oid);
        }
        if (meta.getIdentityType() == ClassMetaData.ID_DATASTORE) {
            // no id field
            try {
                return new Id(cls, ((Number) oid).longValue());
            } catch (ClassCastException cce) {
                // swallow, the proper exception will be thrown below
                expected = Number.class;
            }
        }
View Full Code Here

        assertNotNull(listener2.updated);
        assertNotNull(listener2.deleted);

        boolean pass = false;
        for (Iterator iter = listener2.added.iterator(); iter.hasNext();) {
            Id roid = Id.newInstance(RuntimeTest1.class, oid);
            Id it = (Id) iter.next();
            //FixMe --det. why it.equals(roid) fails when the are actually equal
            if (it.toString().equals(roid.toString())) {
                pass = true;
                break;
            }
        }
        assertTrue("pass = " + pass, pass);
        assertTrue(listener2.updated.size() == 0);
        assertTrue(listener2.deleted.size() == 0);

        // modify an object
        startTx(pm);
        t1.setStringField("baz");
        endTx(pm);

        try {
            Thread.currentThread().sleep(250);
        }
        catch (InterruptedException ie) {
        }

        // ensure that the commit info was not propagated to factory1.
        assertFalse(listener1.commitNotificationReceived);

        // ensure that the commit info propagated to the remote
        // factories correctly.
        assertNotNull(listener2.added);
        assertNotNull(listener2.updated);
        assertNotNull(listener2.deleted);

        pass = false;
        for (Iterator iter = listener2.updated.iterator(); iter.hasNext();) {
            Id it = (Id) iter.next();
            if (it.toString().equals(roid.toString())) {
                pass = true;
                break;
            }
        }
        assertTrue(pass);
        assertTrue(listener2.added.size() == 0);
        assertTrue(listener2.deleted.size() == 0);

        // delete an object
        startTx(pm);
        pm.remove(t1);
        endTx(pm);

        try {
            Thread.currentThread().sleep(250);
        }
        catch (InterruptedException ie) {
        }

        // ensure that the commit info was not propagated to factory1.
        assertFalse(listener1.commitNotificationReceived);

        // ensure that the commit info propagated to the remote
        // factories correctly.
        assertNotNull(listener2.added);
        assertNotNull(listener2.updated);
        assertNotNull(listener2.deleted);

        pass = false;
        for (Iterator iter = listener2.deleted.iterator(); iter.hasNext();) {
            Id it = (Id) iter.next();
            if (it.toString().equals(roid.toString())) {
                pass = true;
                break;
            }
        }
        assertTrue(pass);
View Full Code Here

                        getMetaData(classForName(type), null, true);

                    // construct the oid object
                    Object oid;
                    if (meta.getIdentityType() == meta.ID_DATASTORE)
                        oid = new Id(attrs.getValue("oid"), _conf, null);
                    else
                        oid = PCRegistry.newObjectId(meta.getDescribedType(),
                            attrs.getValue("oid"));

                    // create an ObjectData that will contain the information
View Full Code Here

    public Class<?> getDataStoreIdType(ClassMetaData meta) {
        return Id.class;
    }

    public Object copyDataStoreId(Object oid, ClassMetaData meta) {
        Id id = (Id) oid;
        return new Id(meta.getDescribedType(), id.getId(), id.hasSubclasses());
    }
View Full Code Here

    public Object newDataStoreId(Object val, ClassMetaData meta) {
        return Id.newInstance(meta.getDescribedType(), val);
    }

    public Id newDataStoreId(long id, ClassMapping mapping, boolean subs) {
        return new Id(mapping.getDescribedType(), id, subs);
    }
View Full Code Here

            startTx(em);
            em.persist(a);
            em.persist(aparent);
            oid = em.getObjectId(a);
            oidwithclass = new Id(CacheObjectA.class, oid.toString());
            parentOid = em.getObjectId(aparent);
            endTx(em);
        }
        finally {
            endEm(em);
View Full Code Here

    public void testExpiredRelations() {
        CacheObjectA a = (CacheObjectA) em.find(CacheObjectA.class, oid);
        em.refresh(a);
        Object relationOid = em.getObjectId(a.getRelatedObject());
        relationOid = new Id(CacheObjectA.class, relationOid.toString());

        ClassMetaData meta = repos.getMetaData(CacheObjectA.class, null, true);
        DataCache cache = meta.getDataCache();

        // drop the related data from the cache
View Full Code Here

            em.persist(h);
           
            endTx(em);

            Object[] ids = new Object[4];
            ids[0] = new Id(CacheObjectE.class, em.getObjectId(e).toString());
            ids[1] = new Id(CacheObjectF.class, em.getObjectId(f).toString());
            ids[2] = new Id(CacheObjectG.class, em.getObjectId(g).toString());
            ids[3] = new Id(CacheObjectH.class, em.getObjectId(h).toString());

            // build up some queries to test

            // this one should be only on the superclass, since
            // CacheObjectF has a timeout.
View Full Code Here

TOP

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

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.