Search in sources :

Example 16 with TxVoidWork

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

the class SingletonCollectionsTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            doc1 = new Document("doc1");
            doc2 = new Document("doc2");
            doc3 = new Document("doc3");
            doc4 = new Document("doc4");
            Person o1 = new Person("pers1");
            Person o2 = new Person("pers2");
            Person o3 = new Person("pers3");
            doc1.setOwner(o1);
            doc2.setOwner(o2);
            doc3.setOwner(o2);
            doc4.setOwner(o2);
            em.persist(o1);
            em.persist(o2);
            em.persist(o3);
            em.persist(doc1);
            em.persist(doc2);
            em.persist(doc3);
            em.persist(doc4);
        }
    });
}
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)

Example 17 with TxVoidWork

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

the class EmbeddableCollectionsTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            doc0 = new DocumentForElementCollections("doc0");
            doc1 = new DocumentForElementCollections("doc1");
            doc2 = new DocumentForElementCollections("doc2");
            PersonForElementCollections o1 = new PersonForElementCollections("pers1");
            PersonForElementCollections o2 = new PersonForElementCollections("pers2");
            PersonForElementCollections o3 = new PersonForElementCollections("pers3");
            PersonForElementCollections o4 = new PersonForElementCollections("pers4");
            o1.setPartnerDocument(doc0);
            o2.setPartnerDocument(doc0);
            o3.setPartnerDocument(doc0);
            o4.setPartnerDocument(doc0);
            doc1.setOwner(o1);
            doc2.setOwner(o2);
            doc1.getContacts().put(1, o1);
            doc2.getContacts().put(1, o2);
            doc1.getContacts().put(2, o3);
            doc2.getContacts().put(2, o4);
            doc1.getPartners().add(o1);
            doc1.getPartners().add(o3);
            doc2.getPartners().add(o2);
            doc2.getPartners().add(o4);
            doc1.getPersonList().add(o1);
            doc1.getPersonList().add(o2);
            doc2.getPersonList().add(o3);
            doc2.getPersonList().add(o4);
            em.persist(doc0);
            em.persist(doc1);
            em.persist(doc2);
        }
    });
}
Also used : DocumentForElementCollections(com.blazebit.persistence.view.testsuite.collections.entity.simple.DocumentForElementCollections) EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) PersonForElementCollections(com.blazebit.persistence.view.testsuite.collections.entity.simple.PersonForElementCollections)

Example 18 with TxVoidWork

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

the class SetAsListEntityViewTestTest method setUp.

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

        @Override
        public void work(EntityManager em) {
            entity = new IdClassEntity(1, "1", 1);
            IdClassEntity e2 = new IdClassEntity(2, "2", 2);
            IdClassEntity e3 = new IdClassEntity(3, "3", 3);
            entity.getChildren().add(e2);
            entity.getChildren().add(e3);
            entity.getChildren2().add(e2);
            entity.getChildren2().add(e3);
            em.persist(e2);
            em.persist(e3);
            em.persist(entity);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) IdClassEntity(com.blazebit.persistence.testsuite.entity.IdClassEntity) Before(org.junit.Before)

Example 19 with TxVoidWork

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

the class BasicCollectionsTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            doc1 = new DocumentForCollections("doc1");
            doc2 = new DocumentForCollections("doc2");
            PersonForCollections o1 = new PersonForCollections("pers1");
            PersonForCollections o2 = new PersonForCollections("pers2");
            PersonForCollections o3 = new PersonForCollections("pers3");
            PersonForCollections o4 = new PersonForCollections("pers4");
            o1.setPartnerDocument(doc1);
            o2.setPartnerDocument(doc2);
            o3.setPartnerDocument(doc1);
            o4.setPartnerDocument(doc2);
            doc1.setOwner(o1);
            doc2.setOwner(o2);
            doc1.getContacts().put(1, o1);
            doc2.getContacts().put(1, o2);
            doc1.getContacts().put(2, o3);
            doc2.getContacts().put(2, o4);
            em.persist(o1);
            em.persist(o2);
            em.persist(o3);
            em.persist(o4);
            doc1.getPartners().add(o1);
            doc1.getPartners().add(o3);
            doc2.getPartners().add(o2);
            doc2.getPartners().add(o4);
            doc1.getPersonList().add(o1);
            doc1.getPersonList().add(o2);
            doc2.getPersonList().add(o3);
            doc2.getPersonList().add(o4);
            em.persist(doc1);
            em.persist(doc2);
        }
    });
}
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)

Example 20 with TxVoidWork

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

the class MappingIndexTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            Person p = new Person("p");
            doc1 = new Document("doc1", p, new Version(2), new Version(1));
            doc2 = new Document("doc2", p);
            em.persist(doc1);
            em.persist(doc2);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) Version(com.blazebit.persistence.testsuite.entity.Version) 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