Package org.apache.openjpa.persistence

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


        sql.clear();
        try {
            em.getTransaction().begin();
            if (hint || queryHint) {
                if (hint) {
                    Query q = em.createQuery(
                    "select o from AllFieldTypes o where o.intField = :p");
                    q.setParameter("p", 0);
                    q.setHint("openjpa.hint.OptimizeResultCount"
                         ,new Integer(8));
                    q.getResultList();
View Full Code Here


                    q.setHint("openjpa.hint.OptimizeResultCount"
                         ,new Integer(8));
                    q.getResultList();
                }   
                else {
                    OpenJPAQuery q =  OpenJPAPersistence.cast (em.createQuery
                        ("select o from AllFieldTypes o where o.intField " +
                         "= :p"));
                    q.setParameter("p", 0);
                    q.setHint(q.HINT_RESULT_COUNT, new Integer(8));
                    q.getResultList();
View Full Code Here

        assertEquals("Famzy", user.getName());

        String query = "UPDATE CompUser e SET " +
                "e.name = LOWER(e.name) WHERE LOWER(e.nameAsLob)='famzy'";

        int result = em.createQuery(query).executeUpdate();

        user = em.find(CompUser.class, userid5);
        em.refresh(user);
        assertNotNull(user);
        assertEquals("famzy", user.getName());
View Full Code Here

        assertEquals("Famzy", user.getName());

        String query = "UPDATE CompUser e SET " +
                "e.name = UPPER(e.name) WHERE UPPER(e.nameAsLob)='FAMZY'";

        int result = em.createQuery(query).executeUpdate();

        user = em.find(CompUser.class, userid5);
        em.refresh(user);
        assertNotNull(user);
        assertEquals("FAMZY", user.getName());
View Full Code Here

            em = emf.createEntityManager();

            System.err.println("Main started.");
            int test=1;
            List<Address> addrs = em.createQuery(
                "select o.shipAddress from Order o")
                .getResultList();
            for (Address addr : addrs) {
                System.out.println("addr= " + addr.toString());
            }
View Full Code Here

                "select o from Order o where o.shipAddress.city = 'San Jose'"
            };
            String qstring = null;
            for (int i = 0;i < qstrings.length; i++) {
                qstring = qstrings[i];
                List orders = em.createQuery(qstring).getResultList();
                printOrders(orders, test++);
            }

            // query passing parameters
            qstring = "select o from Order o where o.shipAddress.city = ?1";
View Full Code Here

                printOrders(orders, test++);
            }

            // query passing parameters
            qstring = "select o from Order o where o.shipAddress.city = ?1";
            Query q5 = em.createQuery(qstring);
            q5.setParameter(1, "San Jose");
            List orders =q5.getResultList();
            printOrders(orders, test++);

            qstring = "select o from Order o where ?1 = o.shipAddress.city";
View Full Code Here

            q5.setParameter(1, "San Jose");
            List orders =q5.getResultList();
            printOrders(orders, test++);

            qstring = "select o from Order o where ?1 = o.shipAddress.city";
            Query q6 = em.createQuery(qstring);
            q6.setParameter(1, "San Jose");
            orders = q6.getResultList();
            printOrders(orders, test++);

            em.close();
View Full Code Here

            em.close();
            em = emf.createEntityManager();

            // query after updates
            orders = em.createQuery("select o from Order o").getResultList();
            System.out.println("After Update:");
            printOrders(orders, test++);

            // queries expecting exceptions
            String[] badqstrings = {
View Full Code Here

            for (int i = 0; i < badqstrings.length; i++) {
                qstring = badqstrings[i];
                try {
                    System.out.println("\n>> Query "+test+": "+qstring);
                    test++;
                    orders = em.createQuery(qstring).getResultList();
                }
                catch (Exception e){
                    System.out.println("Exception: "+e);
               
            }
View Full Code Here

TOP
Copyright © 2015 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.