Package org.apache.openjpa.persistence

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


        {
            OpenJPAEntityManager pm = getPM();
            startTx(pm);
            String theQuery =
                "SELECT r FROM RuntimeTest1 r WHERE r.stringField = \'testSimple\'";
            OpenJPAQuery query = pm.createQuery(theQuery);
            RuntimeTest1 toUpdate = (RuntimeTest1) query.getSingleResult();
            toUpdate.setStringField("testSimple2");
            endTx(pm);
            endEm(pm);
View Full Code Here


            startTx(pm);
            String query1 =
                "SELECT r FROM RuntimeTest1 r WHERE r.stringField = \'testSimple\'";
            String query2 =
                "SELECT r FROM RuntimeTest1 r WHERE r.stringField = \'testSimple2\'";
            OpenJPAQuery q1 = pm.createQuery(query1);
            OpenJPAQuery q2 = pm.createQuery(query2);
            assertSize(0, q1.getResultList());
            assertSize(1, q2.getResultList());
            endTx(pm);
            endEm(pm);
View Full Code Here

            String query1 =
                "SELECT r FROM RuntimeTest1 r WHERE r.stringField = \'testSimple\'";
            String query2 =
                "SELECT r FROM RuntimeTest1 r WHERE r.stringField = \'testSimple2\'";
            OpenJPAQuery q1 = pm.createQuery(query1);
            OpenJPAQuery q2 = pm.createQuery(query2);
            assertSize(0, q1.getResultList());
            assertSize(1, q2.getResultList());
            endTx(pm);
            endEm(pm);
        }
View Full Code Here

        {
            OpenJPAEntityManager pm = getPM();
            startTx(pm);
            String delete =
                "DELETE FROM RuntimeTest1 r WHERE r.stringField = \'testSimple2\'";
            OpenJPAQuery deleteQuery = pm.createQuery(delete);
            int deleted = deleteQuery.executeUpdate();
            endTx(pm);
            endEm(pm);

            pm = getPM();
View Full Code Here

            pm = getPM();
            startTx(pm);
            String select =
                "SELECT r FROM RuntimeTest1 r WHERE r.stringField = \'testSimple2\'";
            OpenJPAQuery selectQuery = pm.createQuery(select);

            assertSize(0, selectQuery.getResultList());

            endTx(pm);
            endEm(pm);
View Full Code Here

    CallbackStorage.clearStore();

    String query = "Update Employee e SET e.name = 'Joseph' WHERE e.id = :id";

    int result = em.createQuery(query)
                   .setParameter("id", 5)
                   .executeUpdate();

    List store = CallbackStorage.getInstance().getClist();
View Full Code Here

            assertStatus(1, 1, 0, 0, 0, 0, 0);

            em.clear();

            // Perform a simple query to get the Message
            Query q = em.createQuery("select m from Message m where m.id="
                + message.getId());
            Message m = (Message) q.getSingleResult();

            assertEquals("Test first expected message.", "Hello Persistence!",
                m.getMessage());
View Full Code Here

                .getCreated());
            assertNotNull("Test message's updated field being set.", message
                .getUpdated());

            // Perform a simple query to get the Message
            Query q = em.createQuery("select m from Message m where m.id="
                + message.getId());
            Message m = (Message) q.getSingleResult();
            assertEquals("Test first expected message.", "Hello Persistence!",
                m.getMessage());
            assertNotNull("Test message's created field being set.", m
View Full Code Here

        assertEquals("name1", pc.getName());
        assertEquals(1.0, pc.getPoint().getX());
        assertEquals(2.0, pc.getPoint().getY());
       
        for (int i = 0; i < 2; i++) {
            Query query = em.createQuery("select s from NonstandardMappingEntity4 s where s.point = :point");
            query.setParameter("point", new Point(1, 2));
            java.util.List<NonstandardMappingEntity4> list = query.getResultList();
            for (NonstandardMappingEntity4 pc1 : list) {
                assertEquals(1.0, pc1.getPoint().getX());
                assertEquals(2.0, pc1.getPoint().getY());
View Full Code Here

        em = factory.createEntityManager();
        try {
            startTx(em);

            // find the new object...
            OpenJPAQuery q = em.createQuery("select a FROM "
                + CacheObjectE.class.getSimpleName()
                + " a where a.str = 'e'");
            e = (CacheObjectE) ((Collection) q.getResultList()).iterator()
                .next();
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.