Examples of CacheObjectA


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 =
                ((((OpenJPAEntityManagerFactorySPI) factory2)).getConfiguration())
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

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

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

        startTx(em0);
        CacheObjectA a = (CacheObjectA) em0.find(CacheObjectA.class, oid);

        Date d = new Date();
        a.setDate(d);

        endTx(em0);
        DataCache cache = cacheManager(factory).getDataCache(
            DataCache.NAME_DEFAULT, false);
        assertTrue(cache.contains(oidwithclass));
        cache.remove(oidwithclass);

        a = (CacheObjectA) em1.find(CacheObjectA.class, oid);
        assertTrue(cache.contains(oidwithclass));

        try {
            PCData data = cache.get(oidwithclass);
            ClassMetaData meta =
                ((OpenJPAEntityManagerFactorySPI) OpenJPAPersistence
                    .cast(factory)).getConfiguration()
                    .getMetaDataRepositoryInstance().getMetaData(a.getClass(),
                    null, false);
            FieldMetaData fmd = meta.getField("date");
            d = (Date) data.getData(fmd.getIndex());
            Broker broker = JPAFacadeHelper.toBroker(em1);
            OpenJPAStateManager sm = broker.getStateManager(a);
            assertTrue(sm == ((ProxyDate) a.getDate()).getOwner());
            assertEquals(Date.class, d.getClass());
        }
        finally {
            endEm(em0);
            endEm(em1);
View Full Code Here

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

        broker.close();
    }

    private void doassertTrue(EntityManager em, String name, int age)
        throws Exception {
        CacheObjectA a = (CacheObjectA) em.find(CacheObjectA.class, oid);
        assertTrue(name.equals(a.getName()));
        assertTrue(a.getAge() == age);
        endEm(em);
    }
View Full Code Here

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

        int j = 0;
        for (int i = 0; i < 10; i++) {
            // make some common names so that GROUP BY is useful.
            if (i % 2 == 0)
                j++;
            CacheObjectA o;
            broker.persist(o = new CacheObjectAChild1("", "results-" + j, i),
                null);

            o.setDate(new Date());
            o.setDateArray(new Date[]{ new Date(10), new Date(20) });

            if (i < 5)
                o.setRelatedB(new CacheObjectB());
        }

        //Seetha Oct 30,2006
        //deleteAll closes the TX.  So use the local
        //deleteAll fn.
        //deleteAll(CacheObjectWithExternalizedFields.class,());
        //deleteAll(broker,CacheObjectWithExternalizedFields.class,true);

        CacheObjectWithExternalizedFields o =
            new CacheObjectWithExternalizedFields();
        broker.persist(o, null);
        o.setCls(Broker.class);

        broker.commit();
        broker.close();

        CacheTestHelper.cacheManager(_factory).getSystemQueryCache().clear();
View Full Code Here

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

        clear();

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

        CacheObjectA a;
        CacheObjectA aparent;
        try {
            // we can't specify this for UserTransaction
            /*
                * pm.currentTransaction().setNontransactionalRead(true);
                * pm.currentTransaction().setOptimistic(true);
                */

//      em.setNontransactionalRead(true);
//      em.setOptimistic(true);

            a = new CacheObjectA(ORIG_NAME, ORIG_AGE);
            aparent = new CacheObjectA(ORIG_PARENT_NAME, ORIG_PARENT_AGE);
            a.setRelatedObject(aparent);
            LinkedList children = new LinkedList();
            children.add(a);
            aparent.setRelatedCollection(children);

            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);
        }

        // load an object in a separate pm before the update
        // happens. This should not change, else we're in
        // violation of the spec.
        this.em = factory.createEntityManager();
        startTx(this.em);
        try {
            // OpenJPAEntityManager openEm=(OpenJPAEntityManager) this.em;
            this.a = (CacheObjectA) this.em.find(CacheObjectA.class, oid);

            // load the parent for testCollections().
            CacheObjectA rel = this.a.getRelatedObject();
            rel.getRelatedCollection();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            endTx(this.em);
            // endEm(this.em);
        }

        em = factory.createEntityManager();
        try {
            startTx(em);
            a = (CacheObjectA) em.find(CacheObjectA.class, oid);
            a.setName(NEW_NAME);

            aparent = (CacheObjectA) em.find(CacheObjectA.class, parentOid);

            CacheObjectA a2 = new CacheObjectA(ORIG_NAME, ORIG_AGE);
            a2.setRelatedObject(aparent);
            aparent.getRelatedCollection().add(a2);
            em.persist(a2);
            endTx(em);

            assertNew(a);
View Full Code Here

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

    public void testDeletedOneToOneRelations() throws Exception {
        EntityManager em = factory.createEntityManager();
        try {
            startTx(em);
            CacheObjectA a = (CacheObjectA) em.find(CacheObjectA.class, oid);
            assertNotNull(a.getRelatedObject());
            em.remove(a.getRelatedObject());
            endTx(em);
        }
        finally {
            endEm(em);
        }

        EntityManager em2 = factory.createEntityManager();
        try {
            CacheObjectA a2 = (CacheObjectA) em2.find(CacheObjectA.class, oid);
            assertNull(a2.getRelatedObject());
        }
        finally {
            endEm(em2);
        }
    }
View Full Code Here

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

      * e) { bug(467, "data cache can over-eagerly load relation data"); } }
      * finally { close(pm2); } }
      */

    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();

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.