Search in sources :

Example 21 with TxVoidWork

use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.

the class MultisetFetchCollectionsBenchmarkTest method setUpOnce.

@Override
public void setUpOnce() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            List<DocumentForCollections> docs = new ArrayList<>();
            for (int i = 1; i <= 20; i++) {
                docs.add(new DocumentForCollections("doc" + i));
            }
            DocumentForCollections doc1 = docs.get(0);
            pers1 = new PersonForCollections("pers1");
            for (DocumentForCollections doc : docs) {
                doc.setOwner(pers1);
            }
            doc1.getPersonList().add(pers1);
            for (int i = 2; i <= 20; i++) {
                doc1.getPersonList().add(new PersonForCollections("listPers" + i));
            }
            doc1.getContacts().put(1, pers1);
            for (int i = 2; i <= 20; i++) {
                doc1.getContacts().put(i, new PersonForCollections("contactsPers" + i));
            }
            em.persist(pers1);
            for (PersonForCollections personForCollections : doc1.getPersonList()) {
                em.persist(personForCollections);
            }
            for (PersonForCollections personForCollections : doc1.getContacts().values()) {
                em.persist(personForCollections);
            }
            for (DocumentForCollections doc : docs) {
                em.persist(doc);
            }
            pers1.setPartnerDocument(doc1);
            for (int i = 2; i <= 20; i++) {
                PersonForCollections partner = new PersonForCollections("partnerPers" + i);
                partner.setPartnerDocument(doc1);
                em.persist(partner);
            }
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) PersonForCollections(com.blazebit.persistence.view.testsuite.collections.entity.simple.PersonForCollections) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) DocumentForCollections(com.blazebit.persistence.view.testsuite.collections.entity.simple.DocumentForCollections) ArrayList(java.util.ArrayList) List(java.util.List)

Example 22 with TxVoidWork

use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.

the class InheritanceMappingInAnotherEntityViewTest method setUpOnce.

@Override
public void setUpOnce() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            B b = new B();
            b.setSomeValue((short) 5);
            b.setName("test1");
            em.persist(b);
            C c = new C();
            c.setA(b);
            c.setName("test");
            em.persist(c);
        }
    });
}
Also used : TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork)

Example 23 with TxVoidWork

use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.

the class PolymorphicInheritanceTest method setUpOnce.

@Override
public void setUpOnce() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            base1 = new SingleTableSub1("st1");
            base2 = new SingleTableSub2("st2");
            base1.setSub1Value(123);
            base2.setSub2Value(456);
            em.persist(base1);
            em.persist(base2);
            base1.setParent(base2);
            base2.setParent(base1);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) SingleTableSub1(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub1) SingleTableSub2(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub2)

Example 24 with TxVoidWork

use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.

the class PolymorphicNestedInheritanceTest method setUpOnce.

@Override
public void setUpOnce() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            base1 = new SingleTableSub1("st1");
            base2 = new SingleTableSub2("st2");
            base1.setSub1Value(123);
            base2.setSub2Value(456);
            em.persist(base1);
            em.persist(base2);
            base1.setParent(base2);
            base2.setParent(base1);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) SingleTableSub1(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub1) SingleTableSub2(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub2)

Example 25 with TxVoidWork

use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.

the class AggregateViewPaginationTest method setUpOnce.

@Override
public void setUpOnce() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            doc1 = new Document("doc1");
            Person o1 = new Person("pers1", 10);
            doc1.setAge(10);
            doc1.setOwner(o1);
            doc1.getContacts().put(1, o1);
            doc1.getContacts2().put(2, o1);
            em.persist(o1);
            em.persist(doc1);
            em.persist(new Document("doc2", o1));
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) Document(com.blazebit.persistence.testsuite.entity.Document) Person(com.blazebit.persistence.testsuite.entity.Person)

Aggregations

TxVoidWork (com.blazebit.persistence.testsuite.tx.TxVoidWork)135 EntityManager (javax.persistence.EntityManager)131 Person (com.blazebit.persistence.testsuite.entity.Person)76 Document (com.blazebit.persistence.testsuite.entity.Document)69 Before (org.junit.Before)28 Test (org.junit.Test)15 Version (com.blazebit.persistence.testsuite.entity.Version)14 DocumentForCollections (com.blazebit.persistence.view.testsuite.collections.entity.simple.DocumentForCollections)11 PersonForCollections (com.blazebit.persistence.view.testsuite.collections.entity.simple.PersonForCollections)11 Category (org.junit.experimental.categories.Category)7 IntIdEntity (com.blazebit.persistence.testsuite.entity.IntIdEntity)5 SingleTableSub1 (com.blazebit.persistence.testsuite.treat.entity.SingleTableSub1)5 SingleTableSub2 (com.blazebit.persistence.testsuite.treat.entity.SingleTableSub2)5 PolymorphicSub1 (com.blazebit.persistence.testsuite.entity.PolymorphicSub1)4 PolymorphicSub2 (com.blazebit.persistence.testsuite.entity.PolymorphicSub2)4 TPCSub1 (com.blazebit.persistence.testsuite.entity.TPCSub1)4 TPCSub2 (com.blazebit.persistence.testsuite.entity.TPCSub2)4 CriteriaBuilder (com.blazebit.persistence.CriteriaBuilder)3 EmbeddableTestEntity (com.blazebit.persistence.testsuite.entity.EmbeddableTestEntity)3 EmbeddableTestEntityId (com.blazebit.persistence.testsuite.entity.EmbeddableTestEntityId)3