Package com.oltpbenchmark.benchmarks.jpab

Source Code of com.oltpbenchmark.benchmarks.jpab.JPABLoader

package com.oltpbenchmark.benchmarks.jpab;

import java.sql.Connection;
import java.sql.SQLException;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.apache.commons.lang.NotImplementedException;

import com.oltpbenchmark.api.BenchmarkModule;
import com.oltpbenchmark.api.Loader;
import com.oltpbenchmark.benchmarks.jpab.tests.BasicTest;
import com.oltpbenchmark.benchmarks.jpab.tests.Test;

public class JPABLoader extends Loader {

    String persistanceUnit;
    public JPABLoader(BenchmarkModule benchmark, Connection conn, String persistanceUnit) throws SQLException {
        super(benchmark, conn);
        this.persistanceUnit=persistanceUnit;
    }

    @Override
    public void load() throws SQLException {
        int objectCount= (int)this.workConf.getScaleFactor();
        EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistanceUnit);
        EntityManager em = emf.createEntityManager();
        Test test=new BasicTest();
        test.setBatchSize(10);
        test.setEntityCount(objectCount);
        test.buildInventory(objectCount);
        while (test.getActionCount() < objectCount) {
            System.out.println(test.getActionCount()+ " % "+objectCount);
            test.persist(em);
        }
        test.clearInventory();
    }

}
TOP

Related Classes of com.oltpbenchmark.benchmarks.jpab.JPABLoader

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.