Package org.apache.openjpa.persistence

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactory.createEntityManager()


        Map props = new HashMap();
        props.put("openjpa.FetchGroups", "default,fg1,fg2");
        OpenJPAEntityManagerFactory factory = getEmf(props);

        OpenJPAEntityManager pm =
            (OpenJPAEntityManager) factory.createEntityManager();
        checkGroups(pm, new String[]{ "fg1", "fg2" });
        factory.close();
    }

    public void testFetchGroupsNoConfiguration() {
View Full Code Here


        //FIXME jthomas
        //PersistenceManagerFactory factory = getPMFactory(new String[]{
          //  "openjpa.jdbc.SchemaFactory", "native(ForeignKeys=true)",
        //});
        OpenJPAEntityManagerFactory factory=null;
        OpenJPAEntityManager pm = factory.createEntityManager();
        startTx(pm);
       
       deleteAll( MappingTest1.class,pm);
       deleteAll( MappingTest2.class,pm);
        endTx(pm);
View Full Code Here

       deleteAll( MappingTest1.class,pm);
       deleteAll( MappingTest2.class,pm);
        endTx(pm);
        pm.close();

        pm = factory.createEntityManager();
        startTx(pm);
        for (int i = 0; i < 10; i++) {
            MappingTest5 pc1 = new MappingTest5();
            pc1.setPk1(i);
            pc1.setPk2(i + 1);
View Full Code Here

        endTx(pm);
        pm.close();

        assertSizes(20, MappingTest5.class);

        pm = factory.createEntityManager();
        startTx(pm);
        deleteAll(MappingTest2.class,pm);
        endTx(pm);
        pm.close();
    }
View Full Code Here

            assertEquals("Expected no default lock timeout", lTime.intValue(),
                conf1.getLockTimeout());
            assertEquals("Expected no default query timeout", qTime.intValue(),
                conf1.getQueryTimeout());
            // verify Query receives no properties
            em1 = emf1.createEntityManager();
            assertNotNull(em1);
            q = em1.createNamedQuery("NoHintList");
            // verify no Query hints
            hints = q.getHints();
            assertFalse(hints.containsKey("javax.persistence.lock.timeout"));
View Full Code Here

            assertEquals("Default PU lock timeout", lTime.intValue(),
                conf1.getLockTimeout());
            assertEquals("Default PU query timeout.", qTime.intValue(),
                conf1.getQueryTimeout());
            // verify Query receives the properties
            em1 = emf1.createEntityManager();
            assertNotNull(em1);
            q = em1.createNamedQuery("NoHintList");   
            // Cannot verify properties are passed through as Query hints
            //     See explanation and commented out test in testNoProperties()
            // verify timeout properties supplied in persistence.xml
View Full Code Here

            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

            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

            OpenJPAConfiguration conf = emf.getConfiguration();
            assertNotNull(conf);
            assertEquals("Map provided query timeout", setTime.intValue(),
                conf.getQueryTimeout());
            // create EM and named query
            em = emf.createEntityManager();
            assertNotNull(em);
            OpenJPAQuery q = em.createNamedQuery("Hint1000msec");
            setTime = 1000;
            // verify javax.persistence.query.timeout hint via annotation set
            Map<String, Object> hints = q.getHints();
View Full Code Here

            OpenJPAConfiguration conf = emf.getConfiguration();
            assertNotNull(conf);
            assertEquals("PU provided no query timeout", setTime.intValue(),
                conf.getQueryTimeout());
            // create EM and Query
            em = emf.createEntityManager();
            assertNotNull(em);
            // Following fails to cause a SQLException, but takes 2+ secs
            // Query q = em.createQuery("UPDATE QTimeout q SET q.stringField =
            //     + ":strVal WHERE q.id > 0");
            // q.setParameter("strVal", new String("updated"));
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.