Package org.apache.openjpa.persistence

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


        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();
        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) {
        }
View Full Code Here

    public void tearDown() throws Exception {
        endTx(pm);

        OpenJPAEntityManager newPm = getPM();
        try {
            Object o = newPm.find(RuntimeTest1.class, oid);
            if (o != null) {
                fail("should not be able to load deleted object");
            }
        } catch (Exception e) {
            // expected case
View Full Code Here

        endEm(pm);
    }

    public void testDetach() {
        OpenJPAEntityManager pm = getPM();
        AttachB b = pm.find(AttachB.class, oid);

        assertNotNull("b is null in testDetach", b);

        b = (AttachB) pm.detach(b);
        endEm(pm);
View Full Code Here

        assertEquals(new Integer(5), attached.getStringIntMap().get("5"));
        endTx(pm);
        endEm(pm);

        pm = getPM();
        b = pm.find(AttachB.class, oid);
        assertEquals(12, b.getAint());
        assertEquals("12", b.getBstr());
        assertNull(b.getStringIntMap().get("12"));
        assertEquals(new Integer(5), b.getStringIntMap().get("5"));
        endEm(pm);
View Full Code Here

        OpenJPAEntityManager pm = getPM();
        //FIXME jthomas
//        pm.getFetchPlan().setDetachmentOptions(FetchPlanImpl.DETACH_LOAD_FIELDS | FetchPlanImpl.DETACH_UNLOAD_FIELDS);
        pm.setDetachState(DetachStateType.FETCH_GROUPS);
        pm.getFetchPlan().addFetchGroup("all");
        AttachB b = pm.find(AttachB.class, oid);

        assertNotNull("b is null in testDetachWithGroups", b);

        b = (AttachB) pm.detach(b);
        endEm(pm);
View Full Code Here

            attached.getStringIntMap().get("5"));
        endTx(pm);
        endEm(pm);

        pm = getPM();
        b = (AttachB) pm.find(AttachB.class, oid);
        assertEquals("not equal 12", 12, b.getAint());
        assertEquals("not equal 12str", "12", b.getBstr());
        assertEquals("not equal newinteger(12)", new Integer(12),
            b.getStringIntMap().get("12"));
        assertEquals("not equal newInteger(5)", new Integer(5),
View Full Code Here

        endEm(pm);
    }

    public void testDetachNoOverwrite() {
        OpenJPAEntityManager pm = getPM();
        AttachB b = (AttachB) pm.find(AttachB.class, oid);
        b = (AttachB) pm.detach(b);
        endEm(pm);

        b.setBstr("12");
View Full Code Here

        b.setBstr("12");

        pm = getPM();
        startTx(pm);
        AttachB orig = pm.find(AttachB.class, oid);
        orig.setAint(50);

        AttachB attached = (AttachB) pm.merge(b);
        assertEquals(attached, orig);
        assertEquals(50, attached.getAint());
View Full Code Here

        assertEquals("12", attached.getBstr());
        endTx(pm);
        endEm(pm);

        pm = getPM();
        b = (AttachB) pm.find(AttachB.class, oid);
        assertEquals(50, b.getAint());
        assertEquals("12", b.getBstr());
        endEm(pm);
    }
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.