Package org.apache.openjpa.persistence

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


            String e1Sql = "UPDATE CacheableEntity SET VERSN=?1 WHERE ID=?2";
            String e2Sql = "UPDATE XmlCacheableEntity SET VERSN=?1 WHERE ID=?2";
            em.getTransaction().begin();
            assertEquals(1, em.createNativeQuery(e1Sql).setParameter(1, e1Version + 1).setParameter(2, e1.getId())
                .executeUpdate());
            assertEquals(1, em.createNativeQuery(e2Sql).setParameter(1, e2Version + 1).setParameter(2, e2.getId())
                .executeUpdate());
            em.getTransaction().commit();
            em.refresh(e1);
            em.refresh(e2);
            assertEquals(e1Version + 1, e1.getVersion());
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

            int e2Version = e2.getVersion();

            String e1Sql = "UPDATE CacheableEntity SET VERSN=?1 WHERE ID=?2";
            String e2Sql = "UPDATE XmlCacheableEntity SET VERSN=?1 WHERE ID=?2";
            em.getTransaction().begin();
            assertEquals(1, em.createNativeQuery(e1Sql).setParameter(1, e1Version + 1).setParameter(2, e1.getId())
                .executeUpdate());
            assertEquals(1, em.createNativeQuery(e2Sql).setParameter(1, e2Version + 1).setParameter(2, e2.getId())
                .executeUpdate());
            em.getTransaction().commit();
            em.refresh(e1);
View Full Code Here

            String e1Sql = "UPDATE CacheableEntity SET VERSN=?1 WHERE ID=?2";
            String e2Sql = "UPDATE XmlCacheableEntity SET VERSN=?1 WHERE ID=?2";
            em.getTransaction().begin();
            assertEquals(1, em.createNativeQuery(e1Sql).setParameter(1, e1Version + 1).setParameter(2, e1.getId())
                .executeUpdate());
            assertEquals(1, em.createNativeQuery(e2Sql).setParameter(1, e2Version + 1).setParameter(2, e2.getId())
                .executeUpdate());
            em.getTransaction().commit();
            em.refresh(e1);
            em.refresh(e2);
            assertEquals(e1Version + 1, e1.getVersion());
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());
   
    em.getTransaction().begin();
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

    }

    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

        String[] schemas =
            { "SCHEMA1", "SCHEMA2", "SCHEMA3", "SCHEMA3G", "SCHEMA4G" };
        for (String schema : schemas) {
            try {
                em.getTransaction().begin();
                Query q = em.createNativeQuery("create schema " + schema);
                q.executeUpdate();
                em.getTransaction().commit();
            } catch (PersistenceException e) {         
                em.getTransaction().rollback();
            }
View Full Code Here

        String[] schemas =
            { "SCHEMA1", "SCHEMA2", "SCHEMA3", "SCHEMA3G", "SCHEMA4G" };
        for (String schema : schemas) {
            try {
                em.getTransaction().begin();
                Query q = em.createNativeQuery("create schema " + schema);
                q.executeUpdate();
                em.getTransaction().commit();
            } catch (PersistenceException e) {         
                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.