Package org.objectweb.speedo.runtime.query

Source Code of org.objectweb.speedo.runtime.query.TestDeleteQuery

/**
* Copyright (C) 2001-2006 France Telecom R&D
*/
package org.objectweb.speedo.runtime.query;

import org.objectweb.speedo.SpeedoTestHelper;
import org.objectweb.speedo.pobjects.basic.BasicA;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

public class TestDeleteQuery extends SpeedoTestHelper {

    public TestDeleteQuery(String s) {
        super(s);
    }

    protected String getLoggerName() {
        return LOG_NAME + ".rt.query.TestDeleteQuery";
    }

    public void testSimpleDelete() {
        final int NB_OBJ = 50;
        PersistenceManager pm = pmf.getPersistenceManager();
        pm.currentTransaction().begin();
        for (int i = 0; i < NB_OBJ; i++) {
            pm.makePersistent(new BasicA("testSimpleDelete_" + i, i));
        }
        pm.currentTransaction().commit();
        pm.evictAll();
        pm.currentTransaction().begin();
        Query q = pm.newQuery(BasicA.class);
        long l = q.deletePersistentAll();
        pm.currentTransaction().commit();
        pm.close();
        assertEquals("Bad number of delete object", NB_OBJ, l);
    }
}
TOP

Related Classes of org.objectweb.speedo.runtime.query.TestDeleteQuery

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.