Search in sources :

Example 6 with TxVoidWork

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

the class CustomClassViewTest method setUp.

@Before
public void setUp() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            doc1 = new Document("doc1", 5L);
            doc2 = new Document("doc2", 10L);
            Person o1 = new Person("pers1");
            Person o2 = new Person("pers2");
            o1.getLocalized().put(1, "localized1");
            o2.getLocalized().put(1, "localized2");
            o1.setPartnerDocument(doc1);
            o2.setPartnerDocument(doc2);
            doc1.setOwner(o1);
            doc2.setOwner(o2);
            doc1.getContacts().put(1, o1);
            doc2.getContacts().put(1, o2);
            doc1.getContacts2().put(2, o1);
            doc2.getContacts2().put(2, o2);
            em.persist(o1);
            em.persist(o2);
            em.persist(doc1);
            em.persist(doc2);
        }
    });
    doc1 = em.find(Document.class, doc1.getId());
    doc2 = em.find(Document.class, doc2.getId());
}
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) Before(org.junit.Before)

Example 7 with TxVoidWork

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

the class EmbeddedInheritanceTest method setUpOnce.

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

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

Example 8 with TxVoidWork

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

the class FlatViewPaginationTest method setUp.

@Before
public void setUp() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            for (int i = 1; i <= 10; i++) {
                Person person = new Person("pers" + i);
                em.persist(person);
            }
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) Person(com.blazebit.persistence.testsuite.entity.Person) Before(org.junit.Before)

Example 9 with TxVoidWork

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

the class FlatViewTest method setUp.

@Before
public void setUp() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            doc1 = new Document("doc1");
            doc2 = new Document("doc2");
            Person o1 = new Person("pers1");
            Person o2 = new Person("pers2");
            o1.getLocalized().put(1, "localized1");
            o2.getLocalized().put(1, "localized2");
            o1.setPartnerDocument(doc1);
            o2.setPartnerDocument(doc2);
            doc1.setOwner(o1);
            doc2.setOwner(o2);
            doc1.getContacts().put(1, o1);
            doc2.getContacts().put(1, o2);
            doc1.getContacts2().put(2, o1);
            doc2.getContacts2().put(2, o2);
            em.persist(o1);
            em.persist(o2);
            em.persist(doc1);
            em.persist(doc2);
        }
    });
    doc1 = cbf.create(em, Document.class).where("id").eq(doc1.getId()).fetch("owner").getSingleResult();
    doc2 = cbf.create(em, Document.class).where("id").eq(doc2.getId()).fetch("owner").getSingleResult();
}
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) Before(org.junit.Before)

Example 10 with TxVoidWork

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

the class UpdatableFlatViewTest method setUp.

@Before
public void setUp() {
    cleanDatabase();
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            doc1 = new Document("doc1");
            Person o1 = new Person("pers1");
            doc1.setOwner(o1);
            doc1.getNameMap().put("doc1", new NameObject("doc1", "doc1"));
            doc1.getNameMap().put("doc2", new NameObject("doc1", "doc1"));
            em.persist(o1);
            em.persist(doc1);
        }
    });
    doc1 = cbf.create(em, Document.class).where("id").eq(doc1.getId()).fetch("owner").getSingleResult();
}
Also used : EntityManager(javax.persistence.EntityManager) NameObject(com.blazebit.persistence.testsuite.entity.NameObject) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) Document(com.blazebit.persistence.testsuite.entity.Document) Person(com.blazebit.persistence.testsuite.entity.Person) Before(org.junit.Before)

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