Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.Id


            em.persist(j);
            endTx(em);
            Object hoid = em.getObjectId(h);
            Object joid = em.getObjectId(j);

            Object hoidwithclass = new Id(CacheObjectH.class, hoid.toString());
            Object joidwithclass = new Id(CacheObjectJ.class, joid.toString());
            endEm(em);

            // make sure j and h are in cache; may not be if not LRU
            int attempts = 0;
            for (; attempts < 100 && !cache.contains(joidwithclass); attempts++)
View Full Code Here


        if (oid == null || meta == null)
            return null;

        Class cls = meta.getDescribedType();
        if (meta.getIdentityType() == ClassMetaData.ID_DATASTORE)
            return new Id(cls, ((Number) oid).longValue());

        if (oid instanceof Byte)
            return new ByteId(cls, (Byte) oid);
        if (oid instanceof Character)
            return new CharId(cls, (Character) oid);
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

                        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

        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();
            System.out.println("===ROID: " + roid.getId() + " +++== ITER: " +
                it.getId() + " Content: " + listener2.added + "ROID Cont: " +
                roid);
            System.out.println("Result of COMP " + it.equals(roid));
            //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();
            System.out.println("===ROID: " + roid.getId() + "+++== ITER: " +
                it.getId() + "Content: " + listener2.added);
            System.out.println("Result of COMP " + it.equals(roid));

            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();
            System.out.println("===ROID: " + roid.getId() + "+++== ITER: " +
                it.getId() + "Content: " + listener2.added);
            System.out.println("Result of COMP " + it.equals(roid));

            if (it.toString().equals(roid.toString())) {
                pass = true;
                break;
            }
        }
        assertTrue(pass);
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

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.