Package org.apache.openjpa.persistence

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


        List<Department> param2 = (List<Department>) em.createQuery(jpql2).getResultList();
        em.clear();
       
        String jpql = "select e from Employee e where e.department in :param";
       
        List<Employee> rs1 = em.createQuery(jpql).setParameter("param", param1).getResultList();

        for (int i = 0; i < rs1.size(); i++) {
            Employee e = (Employee) rs1.get(i);
            assertFalse(e.getDepartment().getName().equals("Engineering"));
        }
View Full Code Here


        for (int i = 0; i < rs1.size(); i++) {
            Employee e = (Employee) rs1.get(i);
            assertFalse(e.getDepartment().getName().equals("Engineering"));
        }
       
        List<Employee> rs2 = (List<Employee>) em.createQuery(jpql).setParameter("param", param2).getResultList();
        for (int i = 0; i < rs2.size(); i++) {
            Employee e = (Employee) rs2.get(i);
            assertFalse(e.getDepartment().getName().equals("Sales"));
        }
View Full Code Here

            assertFalse(e.getDepartment().getName().equals("Sales"));
        }

        em.clear();
        String jpql3 = "select e from Employee e where e.department in (:p1, :p2, :p3)";
        Query query = em.createQuery(jpql3);
        query.setParameter("p1", param1.get(0));
        query.setParameter("p2", param1.get(1));
        query.setParameter("p3", param1.get(2));
        List<Employee> rs3 = query.getResultList();
        for (int i = 0; i < rs3.size(); i++) {
View Full Code Here

            Employee e = (Employee) rs3.get(i);
            assertTrue(e.getDepartment().getName().equals("Marketing"));
        }

        em.clear();
        query = em.createQuery(jpql3);
        query.setParameter("p1", param2.get(0));
        query.setParameter("p2", param2.get(1));
        query.setParameter("p3", param2.get(2));
        List<Employee> rs4 = query.getResultList();
        for (int i = 0; i < rs4.size(); i++) {
View Full Code Here

        }

        em.clear();
        String jpql4 = "select p from Parent p where p.id < 3";
        String jpql5 = "select p from Parent p where p.id > 4";
        List<Parent> parm1 = em.createQuery(jpql4).getResultList();
        List<Parent> parm2 = em.createQuery(jpql5).getResultList();
       
        assertTrue("Size of two result list " + parm1.size() + " and " + parm2.size() +
            " must not be same", parm1.size() != parm2.size());
       
View Full Code Here

        em.clear();
        String jpql4 = "select p from Parent p where p.id < 3";
        String jpql5 = "select p from Parent p where p.id > 4";
        List<Parent> parm1 = em.createQuery(jpql4).getResultList();
        List<Parent> parm2 = em.createQuery(jpql5).getResultList();
       
        assertTrue("Size of two result list " + parm1.size() + " and " + parm2.size() +
            " must not be same", parm1.size() != parm2.size());
       
        em.clear();
View Full Code Here

        assertTrue("Size of two result list " + parm1.size() + " and " + parm2.size() +
            " must not be same", parm1.size() != parm2.size());
       
        em.clear();
        String jpql6 = "select c from Child c where c.parent in ?1";
        Query qry = em.createQuery(jpql6);
        qry.setParameter(1, parm1);
        List<Child> c1 = qry.getResultList();
        for (int i = 0; i < c1.size(); i++) {
            Child child = (Child) c1.get(i);
            assertTrue(child.getParent().getId() < 3);
View Full Code Here

            Child child = (Child) c1.get(i);
            assertTrue(child.getParent().getId() < 3);
        }
       
        em.clear();
        qry = em.createQuery(jpql6);
        qry.setParameter(1, parm2);
        List<Child> c2 = qry.getResultList();
        for (int i = 0; i < c2.size(); i++) {
            Child child = (Child) c2.get(i);
            assertTrue(child.getParent().getId() > 4);
View Full Code Here

                    "WHERE ((o1.CustomerId = :customerId) " +
                    "AND    (o1.DistrictId = :districtId) " +
                    "AND    (o1.WarehouseId = :warehouseId)))";
       
        em.getTransaction().begin();
        TypedQuery<OrderJPA> q1 = em.createQuery(jpql, OrderJPA.class);
        q1.setParameter("customerId", 339)
          .setParameter("districtId", 3)
          .setParameter("warehouseId", 23);
                 
        assertEquals(JPQLParser.LANG_JPQL, OpenJPAPersistence.cast(q1).getLanguage());
View Full Code Here

          .setParameter("warehouseId", 23);
                 
        assertEquals(JPQLParser.LANG_JPQL, OpenJPAPersistence.cast(q1).getLanguage());
        assertFalse(q1.getResultList().isEmpty());       
       
        TypedQuery<OrderJPA> q2 = em.createQuery(jpql, OrderJPA.class);
        assertEquals(QueryLanguages.LANG_PREPARED_SQL, OpenJPAPersistence.cast(q2).getLanguage());
        q2.setParameter("customerId", 2967)
          .setParameter("districtId", 5)
          .setParameter("warehouseId", 22);
       
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.