Examples of CacheObjectA


Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

    public void testPCArrays() throws Exception {
        OpenJPAEntityManager newEm = (OpenJPAEntityManager) factory
            .createEntityManager();
        try {
            startTx(newEm);
            CacheObjectA parent = (CacheObjectA) newEm.find(CacheObjectA.class,
                parentOid);
            CacheObjectA a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            a.setRelatedArray(new CacheObjectA[]{ parent, a });
            endTx(newEm);
        }
        finally {
            endEm(newEm);
        }

        newEm = (OpenJPAEntityManager) factory.createEntityManager();
        try {
            a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            CacheObjectA[] array = a.getRelatedArray();
            assertEquals(2, array.length);
            assertTrue(array[0] instanceof CacheObjectA);
            assertTrue(array[1] instanceof CacheObjectA);

            Object arrayOid = newEm.getObjectId(array[0]);
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

    public void testStringArrays() throws Exception {
        OpenJPAEntityManager newEm = (OpenJPAEntityManager) factory
            .createEntityManager();
        try {
            startTx(newEm);
            CacheObjectA a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            a.setStringArray(new String[]{ "string0", "string1", "string2" });
            endTx(newEm);
        }
        finally {
            endEm(newEm);
        }

        newEm = (OpenJPAEntityManager) factory.createEntityManager();
        try {
            a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            String[] array = a.getStringArray();
            assertEquals(3, array.length);
            assertEquals("string0", array[0]);
            assertEquals("string1", array[1]);
            assertEquals("string2", array[2]);
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

    public void testPrimitiveArrays() throws Exception {
        OpenJPAEntityManager newEm = (OpenJPAEntityManager) factory
            .createEntityManager();
        try {
            startTx(newEm);
            CacheObjectA a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            a.setPrimitiveArray(new float[]{ 0, 1, 2 });
            endTx(newEm);
        }
        finally {
            endEm(newEm);
        }

        newEm = (OpenJPAEntityManager) factory.createEntityManager();
        try {
            a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            float[] array = a.getPrimitiveArray();
            assertEquals(3, array.length);
            assertEquals(0.0F, array[0], 0);
            assertEquals(1.0F, array[1], 0);
            assertEquals(2.0f, array[2], 0);
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

    }

    public void testDateArrays() throws Exception {
        OpenJPAEntityManager newEm = (OpenJPAEntityManager) factory
            .createEntityManager();
        CacheObjectA a;
        Date[] dateArray;
        try {
            startTx(newEm);
            a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            dateArray = new Date[]{ new Date(), new Date(), new Date() };
            a.setDateArray(dateArray);
            endTx(newEm);
        }
        finally {
            endEm(newEm);
        }

        newEm = (OpenJPAEntityManager) factory.createEntityManager();
        try {
            a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            Date[] array = a.getDateArray();
            if (array[0] == dateArray[0]) {
                fail("date objects are the same");
            }
        }
        finally {
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

    }

    public void testDate() throws Exception {
        OpenJPAEntityManager newEm = (OpenJPAEntityManager) factory
            .createEntityManager();
        CacheObjectA a;
        Date d;
        try {
            startTx(newEm);
            a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            d = new Date();
            a.setDate(d);
            endTx(newEm);
        }
        finally {
            endEm(newEm);
        }

        // sleep a bit so we can ensure that the date doesn't just
        // happen to be the same.
        Thread.sleep(100);

        newEm = (OpenJPAEntityManager) factory.createEntityManager();
        try {
            a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
            Date d2 = a.getDate();
            if (d == d2) {
                fail("date objects are the same");
            }

            assertEquals(d.getTime(), d2.getTime());
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

    public void testLocale() throws Exception {
        OpenJPAEntityManager newEm = (OpenJPAEntityManager) factory
            .createEntityManager();
        startTx(newEm);
        CacheObjectA a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
        Locale l = Locale.getDefault();
        a.setLocale(l);
        endTx(newEm);

        OpenJPAEntityManager newEm2 = (OpenJPAEntityManager) factory
            .createEntityManager();

        a = (CacheObjectA) newEm2.find(CacheObjectA.class, oid);
        Locale l2 = a.getLocale();
        // locales are immutable and final, so the different cached
        // copies should be ==.
        if (l != l2) {
            fail("locale objects are not the same.");
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

        // make sure that non-manual notification works
        EntityManager em = factory.createEntityManager();
        try {
            startTx(em);
            CacheObjectA a = new CacheObjectA(ORIG_NAME, ORIG_AGE);
            em.persist(a);
            endTx(em);
        }
        finally {
            endEm(em);
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

            (OpenJPAEntityManager) factory.createEntityManager();
        OpenJPAEntityManager em2 = null;
        DataCache cache;

        try {
            CacheObjectA a1 = (CacheObjectA) em1.find(CacheObjectA.class, oid);

            em2 = (OpenJPAEntityManager) factory2.createEntityManager();
            CacheObjectA a2 = (CacheObjectA) em2.find(CacheObjectA.class, oid);

            // assert that the oid is in factory2's cache
            //MetaDataRepository repos2 = factory2.getConfiguration()
            //    .getMetaDataRepositoryInstance();
            MetaDataRepository repos2 =
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

    public void testInterface() throws Exception {
        OpenJPAEntityManager newEm =
            (OpenJPAEntityManager) factory.createEntityManager();
        startTx(newEm);
        CacheObjectA a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);
        CacheObjectC c = new CacheObjectC("blah");
        a.setRelatedInterface(c);
        endTx(newEm);
        Object cId = newEm.getObjectId(c);
        endEm(newEm);

        newEm = (OpenJPAEntityManager) factory.createEntityManager();
        a = (CacheObjectA) newEm.find(CacheObjectA.class, oid);

        CacheObjectInterface c2 = a.getRelatedInterface();
        assertNotNull(c2);

        assertEquals(cId, newEm.getObjectId(c2));
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA

                    + " a where a.name = :pName").setParameter("pName",
                ORIG_NAME);

            c = new ArrayList((Collection) q.getResultList());
            assertEquals(1, c.size());
            CacheObjectA a = (CacheObjectA) c.iterator().next();
            if (related)
                a.getRelatedArray();
            em.detach(a);
            assertEquals(ORIG_NAME, a.getName());
            q.closeAll();
        }
        finally {
            rollbackTx(em);
            endEm(em);
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.