Examples of EntityManagerImpl


Examples of org.apache.openjpa.persistence.EntityManagerImpl

        em.clear();
    }
   
    public void testNullParamsWithNumericPosition01() {
        // Verify Query SQL Cache is enabled
        EntityManagerImpl eml = (EntityManagerImpl) em;
        assertTrue(eml.getQuerySQLCache());
              
        Query q = em.createQuery("SELECT o from QCEntity o WHERE o.amount=?1");
       
        // Test with NULL parameter, SQL should contain a IS NULL predicate
        resetSQL();
View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

    public void testEMConfig002() {
        Map propMap = new HashMap();
        propMap.put("openjpa.jdbc.QuerySQLCache", "true(EnableStatistics=true)");
        EntityManager em = emf.createEntityManager(propMap);
       
        EntityManagerImpl eml = (EntityManagerImpl) em;
        assertTrue(eml.getQuerySQLCache());
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

        assertEquals(1, resultListNull2.size());
    }
   
    public void testNullParamsWithNumericPosition02() {
        // Verify Query SQL Cache is enabled
        EntityManagerImpl eml = (EntityManagerImpl) em;
        assertTrue(eml.getQuerySQLCache());
                     
        // Test with NULL parameter, SQL should contain a IS NULL predicate
        resetSQL();
        Query q1 = em.createQuery("SELECT o from QCEntity o WHERE o.amount=?1");
        q1.setParameter(1, null);
View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

    public void testEMConfig003() {
        Map propMap = new HashMap();
        propMap.put("openjpa.jdbc.QuerySQLCache", "false");
        EntityManager em = emf.createEntityManager(propMap);
       
        EntityManagerImpl eml = (EntityManagerImpl) em;
        assertFalse(eml.getQuerySQLCache());
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

        assertEquals(1, resultListNull2.size());
    }
   
    public void testNullParamsWithNamedQuery01() {
        // Verify Query SQL Cache is enabled
        EntityManagerImpl eml = (EntityManagerImpl) em;
        assertTrue(eml.getQuerySQLCache());       
       
        Query q = em.createNamedQuery("QCEntity.getByAmount");
       
        resetSQL();      
        q.setParameter("amount", null);
View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

    public void testEMConfig004() {
        Map propMap = new HashMap();
        propMap.put("openjpa.jdbc.QuerySQLCache", "false(EnableStatistics=true)");
        EntityManager em = emf.createEntityManager(propMap);
       
        EntityManagerImpl eml = (EntityManagerImpl) em;
        assertFalse(eml.getQuerySQLCache());
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

        em.clear();
    }
   
    public void testNullParamsWithNamedQuery02() {
        // Verify Query SQL Cache is enabled
        EntityManagerImpl eml = (EntityManagerImpl) em;
        assertTrue(eml.getQuerySQLCache());       
       
        resetSQL();
        Query q1A = em.createNamedQuery("QCEntity.getByAmount");
        q1A.setParameter("amount", null);
        List resultListNull1A = q1A.getResultList();
View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

    public void testEMConfig005() {
        Map propMap = new HashMap();
        propMap.put("openjpa.jdbc.QuerySQLCache", "notabool");
        EntityManager em = emf.createEntityManager(propMap);
       
        EntityManagerImpl eml = (EntityManagerImpl) em;
        assertFalse(eml.getQuerySQLCache());
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

     * This test asserts that the ObjectId obtained from the Broker is the same for the following cases: [ An Entity
     * that exists in the current persistence context, a detached Entity with a DetachedStateManager, and a detached
     * Entity with no DetachedStateManager]
     */
    public void testGetObjectId() {
        EntityManagerImpl em = (EntityManagerImpl) emf.createEntityManager();
        Broker broker = em.getBroker();

        em.getTransaction().begin();
        A a = new A();
        em.persist(a);
        Object oidInPersistenceContext = broker.getObjectId(a);
        em.getTransaction().commit();
        em.clear();
        Object oidDetached = broker.getObjectId(a);
        em.close();

        em = (EntityManagerImpl) emf.createEntityManager();
        broker = em.getBroker();
        A a2 = new A();
        a2.setId(a.getId());

        Object oidDetachedNoSm = broker.getObjectId(a2);

View Full Code Here

Examples of org.apache.openjpa.persistence.EntityManagerImpl

                                                          + TblParent.class.getName() + ")");
        props.put("openjpa.jdbc.QuerySQLCache", "true");

        OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.
                                             cast(Persistence.createEntityManagerFactory("test", props));
        EntityManagerImpl em = (EntityManagerImpl)emf.createEntityManager();

        em.getTransaction().begin();

        for (int i = 1; i < 3; i++) {
            TblParent p = new TblParent();
            p.setParentId(i);
            TblChild c = new TblChild();
            c.setChildId(i);
            c.setTblParent(p);
            p.addTblChild(c);
            em.persist(p);
            em.persist(c);

            TblGrandChild gc = new TblGrandChild();
            gc.setGrandChildId(i);
            gc.setTblChild(c);
            c.addTblGrandChild(gc);

            em.persist(p);
            em.persist(c);
            em.persist(gc);
        }
        em.flush();
        em.getTransaction().commit();
        em.clear();

        for (int i = 1; i < 3; i++) {
            TblParent p = em.find(TblParent.class, i);
            int pid = p.getParentId();
            assertEquals(pid, i);
            Collection<TblChild> children = p.getTblChildren();
            boolean hasChild = false;
            for (TblChild c : children) {
                hasChild = true;
                Collection<TblGrandChild> gchildren = c.getTblGrandChildren();
                int cid = c.getChildId();
                assertEquals(cid, i);
                boolean hasGrandChild = false;
                for (TblGrandChild gc : gchildren) {
                    hasGrandChild = true;
                    int gcId = gc.getGrandChildId();
                    assertEquals(gcId, i);
                }
                assertTrue(hasGrandChild);
            }
            assertTrue(hasChild);
        }
        em.close();
        emf.close();
    }
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.