Package org.apache.openjpa.persistence

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


        ListenerImpl listener = new ListenerImpl();
        emf.addLifecycleListener(listener, (Class[]) null);
        OpenJPAEntityManager em = emf.createEntityManager();
        UnenhancedType un = newInstance(sub);
        em.getTransaction().begin();
        em.persist(un);
        em.getTransaction().commit();

        if (!userDefined) {
            em.close();
            em = emf.createEntityManager();
View Full Code Here


    public void testAccessIdBeforeCommit() {
        OpenJPAEntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        IdentityIdClass o = new IdentityIdClass();
        em.persist(o);
        em.getObjectId(o);
        em.getTransaction().commit();
        em.close();
    }
}
View Full Code Here

        OpenJPAEntityManager em = emf.createEntityManager();
        em.getIdGenerator(NonstandardMappingEntity.class).allocate(1);
        sql.clear();
        try {
            em.getTransaction().begin();
            em.persist(e);
            e.getMap().put("foo", "bar");
            em.flush();
            assertEquals(2, sql.size());
            assertSQL(".*NONSTD_MAPPING_MAP.*");
        } finally {
View Full Code Here

        OpenJPAEntityManager em = _emf.createEntityManager();
        em.getTransaction().begin();
        for (int i = 0; i < ORIGINAL_ZIPS.size(); i++) {
            Address a = new Address();
            a.setZip(ORIGINAL_ZIPS.get(i));
            em.persist(a);
        }
        em.getTransaction().commit();
    }
   
    public void testWithCollectionParamOfDifferentSize() {
View Full Code Here

        startTx(pm);
        pc.setStringField("orig");
        pc.setIntField(-11);
        //FIXME jthomas - setDateField
        //pc.setDateField(randomDate());
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);

        if (!newPC) {
            endTx(pm);
            pm = getPM();
View Full Code Here

    public void testCleanOrdering() {
        OpenJPAEntityManager pm = getPM();
        ModRuntimeTest1 pc = new ModRuntimeTest1("orig", 1);
        startTx(pm);
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);
        endTx(pm);
        endEm(pm);

        pm = getPM();
View Full Code Here

        pm = getPM();
        pm.setOptimistic(false);
        startTx(pm);
        ModRuntimeTest1 pc2 = new ModRuntimeTest1("foo", 2);
        pm.persist(pc2);
        pm.setSavepoint("s1");
        pc = (ModRuntimeTest1) pm.find(ModRuntimeTest1.class, oid);
        assertTrue(pm.isTransactional(pc));
        pm.setSavepoint("s2");
        pc.setStringField("bar");
View Full Code Here

    public void testLastSavepoint() {
        OpenJPAEntityManager pm = getPM();
        ModRuntimeTest1 pc = new ModRuntimeTest1("orig", 1);
        startTx(pm);
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);
        endTx(pm);
        endEm(pm);

        pm = getPM();
View Full Code Here

        OpenJPAEntityManager pm = getPM();
        pm.setRetainState(restore);
        startTx(pm);

        for (int i = 0; i < before; i++) {
            pm.persist(new ModRuntimeTest1("s" + i, i));
            //pm.setSavepoint("before" + i);
        }
        pm.setSavepoint("test");

        ModRuntimeTest1 pc = new ModRuntimeTest1();
View Full Code Here

        }
        pm.setSavepoint("test");

        ModRuntimeTest1 pc = new ModRuntimeTest1();
        pc.setStringField("orig");
        pm.persist(pc);
        Object oid = pm.getObjectId(pc);

        for (int i = 0; i < after; i++) {
            pm.persist(new ModRuntimeTest1());
            pm.setSavepoint("after" + i);
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.