Package org.apache.openjpa.persistence.simple

Examples of org.apache.openjpa.persistence.simple.Person


        // Create some entities
        em.getTransaction().begin();
        for (int i = 0; i < nPeople; i++)
        {
            Person p = new Person();
            p.setId(i);
            em.persist(p);
        }
        em.flush();
        em.getTransaction().commit();
        em.close();

        Thread[] newThreads = new Thread[nThreads];
        FindPeople[] customer = new FindPeople[nThreads];
       
        for (int i=0; i < nThreads; i++) {
            customer[i] = new FindPeople(emfac, 0, nPeople,
                nIterations, i);
            newThreads[i] = new Thread(customer[i]);
            newThreads[i].start();
        }
       
        // Wait for the worker threads to complete
        for (int i = 0; i < nThreads; i++) {
            try {
                newThreads[i].join();
            } catch (InterruptedException e) {
                this.fail("Caught Interrupted Exception: " + e);
            }
        }  

        // Run through the state of all runnables to assert if any of them
        // failed.
        for (int i = 0; i < nThreads; i++) {
            assertFalse(customer[i].hadFailures());
        }

        // Clean up the entities used in this test
        em = emfac.createEntityManager();           
        em.getTransaction().begin();

        for (int i = 0; i < nPeople; i++) {
            Person p = em.find(Person.class, i);
            em.remove(p);
        }
        em.flush();
        em.getTransaction().commit();
        em.close();
View Full Code Here


            try {           
                EntityManager em = emf.createEntityManager();           
                for (int j = 0; j < iterations; j++) {
                   
                    for (int i = startId; i < endId; i++) {
                        Person p1 = em.find(Person.class, i);
                        if (p1.getId() != i) {
                            System.out.println("Finder failed: " + i);
                            failures = true;
                            break;
                        }                   
                    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.simple.Person

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.