Package org.apache.openjpa.persistence

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


    }
   
    void loadDB() {
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
        em.getTransaction().begin();
        em.createNativeQuery("INSERT INTO PropertyAccessNoDetachedState (ID,VERSION) VALUES (1,0)")
            .executeUpdate();
        em.createNativeQuery("INSERT INTO FieldAccessNoDetachedState (ID,VERSION) VALUES (1,0)")
            .executeUpdate();
        em.getTransaction().commit();
        em.close();
View Full Code Here


    void loadDB() {
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
        em.getTransaction().begin();
        em.createNativeQuery("INSERT INTO PropertyAccessNoDetachedState (ID,VERSION) VALUES (1,0)")
            .executeUpdate();
        em.createNativeQuery("INSERT INTO FieldAccessNoDetachedState (ID,VERSION) VALUES (1,0)")
            .executeUpdate();
        em.getTransaction().commit();
        em.close();
    }
}
View Full Code Here

        // Modify the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
        String sql = "UPDATE L2_PObject SET NAME='" + MARKER_DATABASE
        + "' WHERE id=" + oid;
        em.createNativeQuery(sql).executeUpdate();
        em.getTransaction().commit();
       
        assertEquals(useDataCache ? MARKER_DATACACHE : MARKER_CACHE,
                pc.getName());
       
View Full Code Here

       
        // delete the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
        String sql = "DELETE FROM L2_PObject WHERE id="+oid;
        em.createNativeQuery(sql).executeUpdate();
        em.getTransaction().commit();
       
        // the object cache does not know that the record was deleted
        assertTrue(em.contains(pc));
        // nor does the data cache
View Full Code Here

        OpenJPAEntityManagerFactorySPI factorySPI = createEMF();
        OpenJPAEntityManagerSPI em = factorySPI.createEntityManager();

        try {
            em.getTransaction().begin();
            Query q = em.createNativeQuery("CREATE SEQUENCE " + sequence + " START WITH 1");
            q.executeUpdate();
            em.getTransaction().commit();
        } catch (PersistenceException e) {         
            // Sequence probably exists.
            em.getTransaction().rollback();
View Full Code Here

    }
   
    void loadDB() {
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
        em.getTransaction().begin();
        em.createNativeQuery("INSERT INTO NoDetachedStateEntityPropertyAccess (ID,VERSION) VALUES (1,0)")
            .executeUpdate();
        em.createNativeQuery("INSERT INTO NoDetachedStateEntityFieldAccess (ID,VERSION) VALUES (1,0)")
            .executeUpdate();
        em.getTransaction().commit();
        em.close();
View Full Code Here

    void loadDB() {
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
        em.getTransaction().begin();
        em.createNativeQuery("INSERT INTO NoDetachedStateEntityPropertyAccess (ID,VERSION) VALUES (1,0)")
            .executeUpdate();
        em.createNativeQuery("INSERT INTO NoDetachedStateEntityFieldAccess (ID,VERSION) VALUES (1,0)")
            .executeUpdate();
        em.getTransaction().commit();
        em.close();
    }
}
View Full Code Here

        // Modify the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
        String sql = "UPDATE PObject SET NAME='" + MARKER_DATABASE
        + "' WHERE id=" + oid;
        em.createNativeQuery(sql).executeUpdate();
        em.getTransaction().commit();
       
        assertEquals(useDataCache ? MARKER_DATACACHE : MARKER_CACHE,
                pc.getName());
       
View Full Code Here

       
        // delete the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
        String sql = "DELETE FROM PObject WHERE id="+oid;
        em.createNativeQuery(sql).executeUpdate();
        em.getTransaction().commit();
       
        // the object cache does not know that the record was deleted
        assertTrue(em.contains(pc));
        // nor does the data cache
View Full Code Here

        OpenJPAEntityManagerFactorySPI factorySPI = createEMF();
        OpenJPAEntityManagerSPI em = factorySPI.createEntityManager();

        try {
            em.getTransaction().begin();
            Query q = em.createNativeQuery("CREATE SEQUENCE " + sequence + " START WITH 1");
            q.executeUpdate();
            em.getTransaction().commit();
        } catch (PersistenceException e) {         
            // Sequence probably exists.
            em.getTransaction().rollback();
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.