Package org.apache.openjpa.persistence

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


        set.add(createInstance(em, 15));
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        pc = em.find(ManagedIface.class, oid);
        set = pc.getSetI();
        assertEquals(4, set.size());
        seen.clear();
        for (Iterator it = set.iterator(); it.hasNext();) {
            rel = (ManagedIface) it.next();
View Full Code Here


        pc.setSetPC(null);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        pc = em.find(ManagedIface.class, oid);
        set = pc.getSetPC();
        assertTrue (set == null || set.size() == 0);
        em.close();
    }
View Full Code Here

        Object oid = em.getObjectId(pc);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        ManagedIface pcx = em.find(ManagedIface.class, oid);
        pc = em.detach(pcx);
        em.close();

        assertTrue(em.isDetached(pc));
        pc.setIntField(7);
View Full Code Here

        em.merge(pc);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        pc = em.find(ManagedIface.class, oid);
        assertEquals(7, pc.getIntField());
        em.close();
    }

    private ManagedIface createInstance(OpenJPAEntityManager em, int i) {
View Full Code Here

    public void testNotDirtyAfterSameChange() {
        OpenJPAEntityManager pm = getPM();
        startTx(pm);

        RuntimeTest1 a = (RuntimeTest1) pm.find(RuntimeTest1.class, oid);
        a.setStringField(a.getStringField());
        OpenJPAStateManager sm = getStateManager(a, pm);
        FieldMetaData fmd = sm.getMetaData().getField("stringField");
        assertTrue(sm.getDirty().get(fmd.getIndex()) == false);
View Full Code Here

        endEm(pm);
    }

    public void testGetById() {
        OpenJPAEntityManager pm = getPM();
        Inner inner = (Inner) pm.find(Inner.class, _oid);
        assertNotNull(inner);
        assertEquals("foo", inner.getString());
        endEm(pm);
    }
View Full Code Here

        OpenJPAEntityManager pm = getPM();
        pm.setOptimistic(false);
        pm.validateChanges();        // no-op outside trans
        startTx(pm);

        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);
        pc.setIntField1(100);

        RuntimeTest1 npc = new RuntimeTest1();
        npc.setIntField(2);
        npc.setIntField1(2);
View Full Code Here

        OpenJPAEntityManager pm = getPM();
        pm.setOptimistic(false);
        pm.validateChanges();        // no-op outside trans
        startTx(pm);

        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);
        pc.setIntField1(100);

        RuntimeTest1 npc = new RuntimeTest1();
        pm.persist(npc);
        Object noid = pm.getObjectId(npc);
View Full Code Here

        endEm(pm);

        pm = getPM();
        try {
            RuntimeTest1 temp =
                (RuntimeTest1) pm.find(RuntimeTest1.class, noid);
            fail("Object should not exist." + temp.getIntField() + "::" +
                temp.getIntField1());
        } catch (Exception jonfe) {
        }
        endEm(pm);
View Full Code Here

        pm.setOptimistic(true);
        pm.validateChanges();        // no-op outside trans
        startTx(pm);
        boolean hasConn = hasConnection(pm);

        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);
        pc.setIntField1(100);

        RuntimeTest1 npc = new RuntimeTest1();
        npc.setIntField(2);
        npc.setIntField1(2);
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.