Package org.apache.openjpa.jdbc.writebehind.entities

Examples of org.apache.openjpa.jdbc.writebehind.entities.SimpleEntity


        em.getTransaction().commit();
    }

    public void updateEntities(boolean flushBetween) {
        em.getTransaction().begin();
        SimpleEntity se = null;
        assertEquals(NUM_INSERTS, _ids.size());
        try {
            for (Integer id : _ids) {
                se = em.find(getEntityType(), id);
                assertNotNull(String.format("%s::%d should be found",
                    getEntityTypeName(), id), se);
                se.setForename(se.getForename() + " UPDATED");
                if (flushBetween) {
                    em.flush();
                }
            }
        } finally {
            em.getTransaction().commit();
        }
       
        em.getTransaction().begin();
        try {
            for (Integer id : _ids) {
                se = em.find(getEntityType(), id);
                assertNotNull(String.format("%s::%d should be found",
                    getEntityTypeName(), id), se);
                se.setSurname(se.getSurname() + " UPDATED");
                if (flushBetween) {
                    em.flush();
                }
            }
        } finally {
View Full Code Here


    }

    public void insertEntities(boolean flushBetween) {
        _ids = new ArrayList<Integer>();
        em.getTransaction().begin();
        SimpleEntity se = null;
        for (int i = 0; i < NUM_INSERTS; i++) {
            se = newEntityInstance();
            if (!idIsGenerated()) {
                se.setId(i + 1);
            }
            se.setForename(NAMES[i % NAMES.length]);
            em.persist(se);
            if (flushBetween) {
                em.flush();
            }
            _ids.add(se.getId());
        }
        em.getTransaction().commit();
    }
View Full Code Here

     */
    protected void populate() {
        _ids = new ArrayList<Integer>();
        EntityManager em = _validatorEMF.createEntityManager();
        em.getTransaction().begin();
        SimpleEntity se = null;
        for (int i = 0; i < NUM_INSERTS; i++) {
            se = newEntityInstance();
            if (!idIsGenerated()) {
                se.setId(i + 1);
            }
            se.setForename(NAMES[i % NAMES.length]);
            se.setSurname(NAMES[(i + 1) % NAMES.length]);
            em.persist(se);
            em.flush();
            _ids.add(se.getId());
        }
        em.getTransaction().commit();
    }
View Full Code Here

     * @throws AssertionFailedError
     *             an entity matching se's ID cannot be found or if any of the
     *             non-version fields do not match
     */
    public void assertEntityContents(EntityManager em, SimpleEntity se) {
        SimpleEntity found = em.find(getEntityType(), se.getId());
        assertNotNull(String.format("%s::%d should be found",
            getEntityTypeName(), 1), found);
        assertTrue(found instanceof SimpleEntity);
        if (se.getForename() != null && se.getForename().length() != 0) {
            assertEquals(se.getForename(), found.getForename());
        }
        if (se.getSurname() != null && se.getSurname().length() != 0) {
            assertEquals(se.getSurname(), found.getSurname());
        }
    }
View Full Code Here

     * Assert that all entities can not be found in the database. No L2 cache or
     * write behind cache is used.
     */
    public void assertEntitiesDeleted() {
        EntityManager validatorEM = getValidatorEMF().createEntityManager();
        SimpleEntity se = null;
        for (int i = 0; i < NUM_INSERTS; i++) {
            se = validatorEM.find(getEntityType(), _ids.get(i));
            assertNull(String.format("%s::%d should have been deleted",
                getEntityTypeName(),_ids.get(i)), se);
        }
View Full Code Here

     * Assert that all entities can be found in the database. No L2 cache or
     * write behind cache is used.
     */
    public void assertEntitiesExist() {
        EntityManager validatorEM = getValidatorEMF().createEntityManager();
        SimpleEntity se = null;
        for (int i = 0; i < NUM_INSERTS; i++) {
            se = validatorEM.find(getEntityType(), _ids.get(i));
            assertNotNull(String.format("%s::%d should exist in the database",
                getEntityTypeName(), _ids.get(i)), se);
        }
View Full Code Here

     * Assert that all entities can not be found in the database and the name
     * field has been updated . No L2 cache or write behind cache is used.
     */
    public void assertEntitiesUpdated() {
        EntityManager validatorEM = getValidatorEMF().createEntityManager();
        SimpleEntity se = null;
        for (int i = 0; i < NUM_INSERTS; i++) {
            se = newEntityInstance();
            se.setId(_ids.get(i));
            se.setForename(NAMES[i % NAMES.length] + " UPDATED");
            se.setSurname(NAMES[(i + 1) % NAMES.length] + " UPDATED");
            assertEntityContents(validatorEM, se);
        }
        validatorEM.close();
    }
View Full Code Here

     * Assert that all entities can not be found in the database and the name
     * fields are unmodified. No L2 cache or write behind cache is used.
     */
    public void assertEntitiesUnmodified() {
        EntityManager validatorEM = getValidatorEMF().createEntityManager();
        SimpleEntity se = null;
        for (int i = 0; i < NUM_INSERTS; i++) {
            se = newEntityInstance();
            se.setId(_ids.get(i));
            se.setForename(NAMES[i % NAMES.length]);
            assertEntityContents(validatorEM, se);
        }
        validatorEM.close();
    }
View Full Code Here

    // begin operations

    public void deleteEntities(boolean flushBetween) {
        assertEntitiesExist();
        em.getTransaction().begin();
        SimpleEntity se = null;
        for (int i = 0; i < NUM_INSERTS; i++) {
            se = em.find(getEntityType(),_ids.get(i));
            em.remove(se);
            if (flushBetween) {
                em.flush();
View Full Code Here

TOP

Related Classes of org.apache.openjpa.jdbc.writebehind.entities.SimpleEntity

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.