Package org.apache.openjpa.persistence.kernel.common.apps

Examples of org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest1


  public void setUp()
  {
    deleteAll (RuntimeTest1.class);
    EntityManager pm = currentEntityManager();
    pm.getTransaction ().begin ();
    pm.persist(new RuntimeTest1("foo", 3));
    endTx(pm);
    endEm(pm);
  }
View Full Code Here


        _factory = (OpenJPAEntityManagerFactory) getEmf(propsMap);

        OpenJPAEntityManager pm = getLockingPM();
        startTx(pm);

        RuntimeTest1 a = new RuntimeTest1("name", 0);
        pm.persist(a);
        _id = pm.getObjectId(a);

        endTx(pm);
        endEm(pm);
View Full Code Here

        if (t2.exception != null)
            throw t2.exception;

        getLog().trace("verifying pessimistic locking worked...");
        OpenJPAEntityManager pm = getLockingPM();
        RuntimeTest1 a = (RuntimeTest1) pm.find(RuntimeTest1.class, _id);
        assertEquals(20 - _bugCount, a.getIntField1());
        getLog().trace("closing pm");
        endEm(pm);
        getLog().trace("done");
    }
View Full Code Here

        Collection results = (Collection) query.getResultList();
        return results;
    }

    private void persist(RuntimeTest1 parent, OpenJPAEntityManager pm) {
        RuntimeTest1 child;
        for (int i = 0; i < CHILD_COUNT; i++) {
            child = newRuntimeTest1("CHILD" + i, i * 10);
            child.setSelfOneOne(parent);
            parent.getSelfOneMany().add(child);
        }

        startTx(pm);
        pm.persist(parent);
View Full Code Here

        pm.persist(parent);
        endTx(pm);
    }

    private RuntimeTest1 newRuntimeTest1(String stringField, int intField) {
        RuntimeTest1 pc = new RuntimeTest1(stringField, intField);
        pc.setIntField(id++);
        return pc;
    }
View Full Code Here

    }

    public void testLocales() {
        EntityManager pm = currentEntityManager();
        startTx(pm);
        RuntimeTest1 t1 = new RuntimeTest1(1);
        t1.setLocaleField(new Locale(Locale.FRANCE.getCountry(),
            Locale.FRENCH.getLanguage()));
        pm.persist(t1);
        pm.persist(new RuntimeTest1(2));
        endTx(pm);
        endEm(pm);

        pm = currentEntityManager();
        List c = findAll(RuntimeTest1.class, pm);
        assertEquals(2, c.size());

        boolean foundNull = false;
        boolean foundFrance = false;
        Locale locale;

        for (Iterator iter = c.iterator(); iter.hasNext();) {
            t1 = (RuntimeTest1) iter.next();
            locale = t1.getLocaleField();
            if (locale == null)
                foundNull = true;
            else if (
                (locale.getCountry().equals(Locale.FRANCE.getCountry())) &&
                    (locale.getLanguage().equals(Locale.FRANCE.getLanguage())))
View Full Code Here

        deleteAll(RuntimeTest3.class);

        // create some instances to query on
        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        pm.persist(new RuntimeTest1("RuntimeTest1-instance", 2));
        pm.persist(new RuntimeTest2("RuntimeTest2-instance", 3));
        pm.persist(new RuntimeTest3("RuntimeTest3-instance", 4));
        endTx(pm);
        endEm(pm);
    }
View Full Code Here

        props.put("openjpa.SavepointManager",
            TrackingSavepointManager.class.getName() + "(AllowFlush=false)");
        OpenJPAEntityManagerFactory pmf = getEmf(props);
        OpenJPAEntityManager pm = pmf.createEntityManager();
        startTx(pm);
        pm.persist(new RuntimeTest1());
        pm.setSavepoint("a");
        try {
            pm.flush();
            fail("should have failed.");
        } catch (Exception e) {
View Full Code Here

            TrackingSavepointManager.class.getName() + "(AllowFlush=false)");
        OpenJPAEntityManagerFactory pmf = getEmf(props);
        OpenJPAEntityManager pm = pmf.createEntityManager();

        startTx(pm);
        pm.persist(new RuntimeTest1());
        pm.flush();
        try {
            pm.setSavepoint("a");
            fail("should have failed.");
        } catch (Exception e) {
View Full Code Here

            TrackingSavepointManager.class.getName() + "(AllowFlush=true)");
        OpenJPAEntityManagerFactory pmf = getEmf(props);
        OpenJPAEntityManager pm = pmf.createEntityManager();

        startTx(pm);
        pm.persist(new RuntimeTest1());
        pm.setSavepoint("a");
        try {
            pm.flush();
        } catch (Exception e) {
            fail("allows flush.");
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest1

Copyright © 2018 www.massapicom. 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.