Package com.mysql.clusterj.jpatest.model

Examples of com.mysql.clusterj.jpatest.model.LongLongStringFKManyOne


            em.persist(a0);
        }
        Collection<LongLongStringFKManyOne> bs = new HashSet<LongLongStringFKManyOne>();
        print("Creating " + NUMBER_OF_B + " instances of LongLongStringFKManyOne.");
        for (int i = OFFSET_B; i < OFFSET_B + NUMBER_OF_B; ++i) {
            LongLongStringFKManyOne b = LongLongStringFKManyOne.create(i);
            b.setLongLongStringPKRelationship(a0);
            bs.add(b);
            em.persist(b);
        }
        a0.setLongLongStringFKRelationships(bs);
        print("Before commit, " + a0.toString());
        for (LongLongStringFKManyOne b:bs){print(b.toString());}
        commit();
        em.close();

        em = emf.createEntityManager();
        print("Finding " + NUMBER_OF_A + " instances of LongLongStringPKOneMany.");
        begin();
        for (int i = OFFSET_A; i < OFFSET_A + NUMBER_OF_A; ++i) {
            LongLongStringOid oid = new LongLongStringOid(i);
            a = em.find(LongLongStringPKOneMany.class, oid);
        }
        print("Finding " + NUMBER_OF_B + " instances of LongLongStringFKManyOne.");
        for (int i = OFFSET_B; i < OFFSET_B + NUMBER_OF_B; ++i) {
            LongLongStringOid oid = new LongLongStringOid(i);
            LongLongStringFKManyOne b = em.find(LongLongStringFKManyOne.class, oid);
            print(b.toString());
        }
        commit();
        em.close();

        /** Update every other instance of B to refer to a different A. */
        em = emf.createEntityManager();
        print("Finding 1 instance of A.");
        begin();
        LongLongStringOid oid = new LongLongStringOid(OFFSET_A);
        a = em.find(LongLongStringPKOneMany.class, oid);
        print("Finding 2 instances of B.");
        for (int i = OFFSET_B; i < OFFSET_B + NUMBER_OF_B; i += 2) {
            oid = new LongLongStringOid(i);
            LongLongStringFKManyOne b = em.find(LongLongStringFKManyOne.class, oid);
            // update every other one
            b.setLongLongStringPKRelationship(a);
            print(b.toString());
        }
        print("After update: " + a0.toString());
        commit();
        em.close();

        em = emf.createEntityManager();
        print("Finding " + NUMBER_OF_A + " instances of A.");
        begin();
        for (int i = OFFSET_A; i < OFFSET_A + NUMBER_OF_A; ++i) {
            oid = new LongLongStringOid(i);
            a = em.find(LongLongStringPKOneMany.class, oid);
            as.add(a);
            print(a.toString());
        }
        print("Finding " + NUMBER_OF_B + " instances of B.");
        for (int i = OFFSET_B; i < OFFSET_B + NUMBER_OF_B; ++i) {
            oid = new LongLongStringOid(i);
            LongLongStringFKManyOne b = em.find(LongLongStringFKManyOne.class, oid);
            print(b.toString());
            if (0 == i%2) {
                errorIfNotEqual("Mismatch in relationship longLongStringPKRelationship",
                        as.get(0), b.getLongLongStringPKOneMany());
                errorIfNotEqual("A.longLongStringFKRelationships should contain longLongStringFKRelationship",
                        true, as.get(0).getLongLongStringFKRelationships().contains(b));
            } else {
                errorIfNotEqual("Mismatch in relationship longLongStringPKRelationship",
                        as.get(1), b.getLongLongStringPKOneMany());
                errorIfNotEqual("A.longLongStringFKRelationships should contain longLongStringFKRelationship",
                        true, as.get(1).getLongLongStringFKRelationships().contains(b));
            }
        }
        commit();
View Full Code Here

TOP

Related Classes of com.mysql.clusterj.jpatest.model.LongLongStringFKManyOne

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.