Examples of OpenJPAEntityManagerFactory


Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

            getLog().trace("testQueryTimeout6 - test is " +
                "being skipped for " + dict.platform);
            return;
        }
        getLog().trace("testQueryTimeout6() - No EM.find() update timeout");
        OpenJPAEntityManagerFactory emf = null;
        OpenJPAEntityManager em = null;
        Integer setTime = new Integer(1000);
       
        try {
            // create our EMF with our PU set timeout property
            emf = OpenJPAPersistence.createEntityManagerFactory(
                "qtimeout-1000msecs", "persistence3.xml");
            assertNotNull(emf);
            // verify PU properties updated the config
            OpenJPAConfiguration conf = emf.getConfiguration();
            assertNotNull(conf);
            assertEquals("PU provided timeout", setTime.intValue(),
                conf.getQueryTimeout());
            // create EM
            em = emf.createEntityManager();
            assertNotNull(em);

            try {
                long startTime = System.currentTimeMillis();
                QTimeout qt = em.find(QTimeout.class, new Integer(1));
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

                "kodo-prefixed properties must be converted to openjpa. " +
                    "Properties: " + keys);

        addProperties(map);

        OpenJPAEntityManagerFactory emf = emfs.get(map);
        if (emf != null) {
            return emf;
        }

        if (props != null) {
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

    }

    public void coreTestTransAndChange(ChangeOperation changeOperation,
        boolean asLargeTransaction, boolean isDelete) {
        // Create two pmfs in a cluster that are using RCPTCP.
        OpenJPAEntityManagerFactory pmfSender = createDistinctFactory(
            TCPRemoteCommitProvider.class,
            "Port=5636, Addresses=127.0.0.1:6636");
        OpenJPAEntityManagerFactory pmfReceiver = createDistinctFactory(
            TCPRemoteCommitProvider.class,
            "Port=6636, Addresses=127.0.0.1:5636");
        // Get the datacaches from each pmf
        DataCache dcSender =
            ((OpenJPAEntityManagerFactorySPI) pmfSender).getConfiguration()
                .getDataCacheManagerInstance().getSystemDataCache();
        DataCache dcReceiver =
            ((OpenJPAEntityManagerFactorySPI) pmfReceiver).getConfiguration()
                .getDataCacheManagerInstance().getSystemDataCache();

        deleteAll(RuntimeTest1.class);
        deleteAll(RuntimeTest2.class);

        _runtime1sOids = null;
        _runtime2sOids = null;

        String transType = "normal";
        String rcpType = "OIDs";
        if (asLargeTransaction) {
            transType = "large";
            rcpType = "classes";
        }
        System.out.println("-------------------");
        System.out.println(
            "2 PMFs created, acting as a cluster using ports 5636 and 6636");
        System.out.println("Testing scenario:");
        System.out
            .println("  1 Seed datastore with instances of RuntimeTest1 AND "
                + "RuntimeTest2 objs.\n"
                + "  2 pmf2 fills its cache with both sets of objs.\n"
                + "  3 pmf1 does a "
                + transType
                + " tx that invokes an operation of "
                + changeOperation.getName()
                + " to affect a single Runtime1 \n"
                + "    assert that both pmf1 and pmf2's data caches dropped all"
                + "Runtime1s");
        System.out.println("Remote commit event is transmiting " + rcpType);

        // Create runtimes1s and 2s.
        // Noraml transaction
        OpenJPAEntityManager pmSender = (OpenJPAEntityManager) pmfSender
            .createEntityManager();
        seedDataStore(pmSender, NUM_OBJECTS);
        endEm(pmSender);

        // wait a bit so they get stored
        pause(1);

        OpenJPAEntityManager pm2;
        pm2 = (OpenJPAEntityManager) pmfReceiver.createEntityManager();
        performLoadAll(pm2);
        endEm(pm2);

        pmSender = (OpenJPAEntityManager) pmfSender.createEntityManager();
        performLoadAll(pmSender);
        endEm(pmSender);

        // assert that pmf2's data cache now has all the Runtime1 and 2s.
        for (int i = 0; i < _runtime1sOids.length; i++) {
            assertTrue(dcReceiver.contains(
                Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
        }
        for (int i = 0; i < _runtime2sOids.length; i++) {
            assertTrue(dcReceiver.contains(
                Id.newInstance(RuntimeTest2.class, _runtime2sOids[i])));
        }

        // Modify or delete exactly 1 RuntimeTest1 object during a
        // largeTransaction
        changeOperation.operation(pmfSender, asLargeTransaction);

        // assert that pmf1's data cache now only has Runtime2 objects
        if (asLargeTransaction) {
            for (int i = 0; i < _runtime1sOids.length; i++) {
                assertFalse(dcSender.contains(
                    Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
            }
        } else {
            // Normal transaction
            for (int i = 0; i < _runtime1sOids.length; i++) {
                if (isDelete && i == 0) {
                    assertFalse(dcSender.contains(
                        Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
                } else {
                    // modified the first elemnt, which just updated it.
                    // (for Kodo's data cache).
                    assertTrue(dcSender.contains(
                        Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
                }
            }
        }
        for (int i = 0; i < _runtime2sOids.length; i++) {
            assertTrue(dcSender.contains(
                Id.newInstance(RuntimeTest2.class, _runtime2sOids[i])));
        }
        // wait a tiny bit so the rce propagates
        pause(2);
        // assert the pmf2's data cache also now only has Runtime2 objects
        if (asLargeTransaction) {
            for (int i = 0; i < _runtime1sOids.length; i++) {
                assertFalse(dcReceiver.contains(Id.newInstance(
                    RuntimeTest1.class, _runtime1sOids[i]))); //failing here
            }
        } else {
            for (int i = 0; i < _runtime1sOids.length; i++) {
                if (i == 0) {
                    assertFalse(dcReceiver.contains(Id.newInstance(
                        RuntimeTest1.class,
                        _runtime1sOids[i])))//failing here
                } else {
                    assertTrue(dcReceiver.contains(
                        Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
                }
            }
        }
        for (int i = 0; i < _runtime2sOids.length; i++) {
            assertTrue(dcReceiver.contains(
                Id.newInstance(RuntimeTest2.class, _runtime2sOids[i])));
        }

        // shutdown
        pmfSender.close();
        pmfReceiver.close();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

        super();
    }

    @Override
    public OpenJPAEntityManagerFactory createEntityManagerFactory(String name, String resource, Map m) {
        OpenJPAEntityManagerFactory factory = super.createEntityManagerFactory(name, resource, m);
        JUDDIEntityManagerFactory juddiEntityManagerFactory = new JUDDIEntityManagerFactory(factory);
        return juddiEntityManagerFactory;
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

        return juddiEntityManagerFactory;
    }

    @Override
    public OpenJPAEntityManagerFactory createEntityManagerFactory(String name, Map m) {
        OpenJPAEntityManagerFactory factory = super.createEntityManagerFactory(name, m);
        JUDDIEntityManagerFactory juddiEntityManagerFactory = new JUDDIEntityManagerFactory(factory);
        return juddiEntityManagerFactory;
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

        return juddiEntityManagerFactory;
    }

    @Override
    public OpenJPAEntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo pui, Map m) {
        OpenJPAEntityManagerFactory factory = super.createContainerEntityManagerFactory(pui, m);
        JUDDIEntityManagerFactory juddiEntityManagerFactory = new JUDDIEntityManagerFactory(factory);
        return juddiEntityManagerFactory;
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

     * Fetches a reference to the EntityManagerFactory's query cache
     * object.
     *
     */
    protected ConcurrentQueryCache getQueryCache() {
        OpenJPAEntityManagerFactory oemf = OpenJPAPersistence.cast(emf);
        QueryResultCacheImpl scache =
            (QueryResultCacheImpl) oemf.getQueryResultCache();

        return (ConcurrentQueryCache) scache.getDelegate();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

    public TestSchemaGenerator(String name) {
        super(name);
    }

    public void testSchemaGen() throws Exception {
        OpenJPAEntityManagerFactory pmf = (OpenJPAEntityManagerFactory) getEmf();
        OpenJPAEntityManager pm = pmf.createEntityManager();
        JDBCConfiguration conf = (JDBCConfiguration) ((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration();

        StringWriter sw = new StringWriter();

        SchemaTool.Flags flags = new SchemaTool.Flags();
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

            getLog().trace("testQueryTimeout21b - test is " +
                "being skipped for " + dict.platform);
            return;
        }
        getLog().trace("testQueryTimeout21b() - Map(timeout=0)");
        OpenJPAEntityManagerFactory emf = null;
        OpenJPAEntityManager em = null;
        Integer setTime = new Integer(0);
        // create the Map to test overrides
        Map<String,String >props = new HashMap<String,String>();
        props.put("javax.persistence.query.timeout", "0");
       
        try {
            // create our EMF with our timeout property
            emf = OpenJPAPersistence.createEntityManagerFactory(
                "qtimeout-no-properties", "persistence3.xml", props);
            assertNotNull(emf);
            // verify Map properties updated the config
            OpenJPAConfiguration conf = emf.getConfiguration();
            assertNotNull(conf);
            assertEquals("Map provided query timeout", setTime.intValue(),
                conf.getQueryTimeout());
            // verify no default javax.persistence.query.timeout is supplied
            // as the Map properties are not passed through as hints
            em = emf.createEntityManager();
            assertNotNull(em);
            OpenJPAQuery q = em.createNamedQuery("NoHintSingle");
            Map<String, Object> hints = q.getHints();
            assertFalse(hints.containsKey("javax.persistence.query.timeout"));
            // verify internal config values were updated
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory

                "being skipped for " + dict.platform);
            return;
        }
        getLog().trace("testQueryTimeout31c() - PU(timeout=1000), " +
            "executeUpdate timeout");
        OpenJPAEntityManagerFactory emf = null;
        OpenJPAEntityManager em = null;
        Integer setTime = new Integer(1000);
        boolean bRetry = true;

        try {
            // create our EMF with our PU set timeout property
            emf = OpenJPAPersistence.createEntityManagerFactory(
                "qtimeout-1000msecs", "persistence3.xml");
            assertNotNull(emf);
            // verify PU properties updated the config
            OpenJPAConfiguration conf = emf.getConfiguration();
            assertNotNull(conf);
            assertEquals("PU provided query timeout", setTime.intValue(),
                conf.getQueryTimeout());
            // create EM and Query
            em = emf.createEntityManager();
            assertNotNull(em);
            OpenJPAQuery q = em.createNativeQuery(nativeUpdateStr);
            q.setParameter(1, new String("updated"));
            // verify no default javax.persistence.query.timeout is supplied
            Map<String, Object> hints = q.getHints();
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.