Package org.apache.openjpa.persistence

Examples of org.apache.openjpa.persistence.OpenJPAEntityManager.createNamedQuery()


            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();
            assertTrue(hints.containsKey("javax.persistence.query.timeout"));
            Integer timeout = new Integer((String) hints.get(
View Full Code Here


            assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
            assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
        }
       
        OpenJPAEntityManager oem = (OpenJPAEntityManager)em;
        OpenJPAQuery<?> q = oem.createNamedQuery("findEmployeeById").setParameter("id", 0);
        FetchPlan fp = q.getFetchPlan();
        fp.setReadLockMode(LockModeType.NONE);

        em.getTransaction().commit();
    }
View Full Code Here

        lockClause = getForUpdateClause();
        assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
        assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
       
        OpenJPAEntityManager oem = (OpenJPAEntityManager)em;
        OpenJPAQuery<?> q = oem.createNamedQuery("findEmployeeById").setParameter("id", 0);
        FetchPlan fp = q.getFetchPlan();
        fp.setReadLockMode(LockModeType.NONE);

        em.getTransaction().commit();
        em.close();
View Full Code Here

            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"));
            assertFalse(hints.containsKey("javax.persistence.query.timeout"));
            // verify default config values of no timeouts
View Full Code Here

            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
            timeout = q.getFetchPlan().getLockTimeout();
            assertEquals("Expected default PU lock timeout", lTime.intValue(),
View Full Code Here

        endEm(pm);
    }

    public void testNamespace() {
        OpenJPAEntityManager pm = getEM();
        OpenJPAQuery query = (OpenJPAQuery) pm.createNamedQuery("named");
        assertEquals("SELECT o FROM QueryTest1 o", query.getQueryString());
        query.closeAll();
        endEm(pm);
    }
View Full Code Here

    public void testSystemJDOQL() {
        // make sure local query metadata is parsed
        OpenJPAEntityManager pm = getEM();

        OpenJPAQuery query = (OpenJPAQuery) pm.createNamedQuery("named");
        assertEquals("SELECT o FROM QueryTest1 o", query.getQueryString());
        assertEquals(QueryTest1.class, query.getResultClass());
        assertEquals(10, ((Collection) query.getResultList()).size());
        query.closeAll();
        endEm(pm);
View Full Code Here

    }
   
    public void testInterfaceResultClass() {
        OpenJPAEntityManager pm = getEM();

        TypedQuery<EntityInterface> query = pm.createNamedQuery("named", EntityInterface.class);
        assertEquals(10, query.getResultList().size());
    }
}
View Full Code Here

    User u = null;
    if (user_id > 0) {
      OpenJPAEntityManager oem = OpenJPAPersistence.cast(em);
      boolean qrce = oem.getFetchPlan().getQueryResultCacheEnabled();
      oem.getFetchPlan().setQueryResultCacheEnabled(false); //FIXME update in cache during update
      TypedQuery<User> q = oem.createNamedQuery("getUserById", User.class).setParameter("id", user_id);
      @SuppressWarnings("unchecked")
      OpenJPAQuery<User> kq = OpenJPAPersistence.cast(q);
      kq.getFetchPlan().addFetchGroup("orgUsers");
      if (force) {
        kq.getFetchPlan().addFetchGroup("backupexport");
View Full Code Here

            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"));
            assertFalse(hints.containsKey("javax.persistence.query.timeout"));
            // verify default config values of no timeouts
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.