Search in sources :

Example 91 with TxVoidWork

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

the class SubviewInheritanceTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            Person o1 = new Person("pers1", 1);
            Person o2 = new Person("pers2", 1);
            Person o3 = new Person("pers3", 15);
            Person o4 = new Person("pers4", 15);
            Person o5 = new Person("pers5", 16);
            Person o6 = new Person("pers6", 16);
            doc1 = new Document("doc1", o1);
            doc2 = new Document("doc2", o2);
            doc3 = new Document("doc3", o3);
            doc4 = new Document("doc4", o4);
            doc5 = new Document("doc5", o5);
            doc6 = new Document("doc6", o6);
            em.persist(o1);
            em.persist(o2);
            em.persist(o3);
            em.persist(o4);
            em.persist(o5);
            em.persist(o6);
            em.persist(doc1);
            em.persist(doc2);
            em.persist(doc3);
            em.persist(doc4);
            em.persist(doc5);
            em.persist(doc6);
            o1.setFriend(o2);
            o2.setPartnerDocument(doc1);
            o3.setFriend(o4);
            o4.setPartnerDocument(doc3);
            o5.setFriend(o6);
            o6.setPartnerDocument(doc5);
        }
    });
}
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 92 with TxVoidWork

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

the class MappingSubqueryTest method setUpOnce.

@Override
public void setUpOnce() {
    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");
            Person o3 = new Person("pers3");
            o1.getLocalized().put(1, "localized1");
            o2.getLocalized().put(1, "localized2");
            o3.getLocalized().put(1, "localized3");
            doc1.setAge(10);
            doc1.setOwner(o1);
            doc2.setAge(20);
            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(o3);
            // Flush doc1 before so we get the ids we would expect
            em.persist(doc1);
            em.flush();
            em.persist(doc2);
            em.flush();
            o1.setPartnerDocument(doc1);
            o2.setPartnerDocument(doc2);
            o3.setPartnerDocument(doc2);
        }
    });
}
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 93 with TxVoidWork

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

the class JsonAndXmlTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            Person p = new Person("Pers1");
            p.setAge(20L);
            em.persist(p);
            Version v1 = new Version();
            v1.setUrl("a");
            Document doc1 = new Document("Doc1", p, v1);
            em.persist(doc1);
            em.persist(v1);
            Version v2 = new Version();
            v2.setUrl("b");
            Document doc2 = new Document("Doc1", p, v2);
            em.persist(doc2);
            em.persist(v2);
            Version v3 = new Version();
            v3.setUrl("c");
            Document doc3 = new Document("Doc2", p, v3);
            em.persist(doc3);
            em.persist(v3);
        }
    });
}
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)

Example 94 with TxVoidWork

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

the class KeysetPaginationNullsTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            KeysetEntity k01 = new KeysetEntity(1, null, null);
            KeysetEntity k02 = new KeysetEntity(2, null, null);
            KeysetEntity k03 = new KeysetEntity(3, 0, null);
            KeysetEntity k04 = new KeysetEntity(4, 1, null);
            KeysetEntity k05 = new KeysetEntity(5, 1, null);
            KeysetEntity k06 = new KeysetEntity(6, 2, null);
            KeysetEntity k07 = new KeysetEntity(7, null, 0);
            KeysetEntity k08 = new KeysetEntity(8, null, 1);
            KeysetEntity k09 = new KeysetEntity(9, null, 1);
            KeysetEntity k10 = new KeysetEntity(10, null, 2);
            KeysetEntity k11 = new KeysetEntity(11, 0, 0);
            KeysetEntity k12 = new KeysetEntity(12, 0, 1);
            KeysetEntity k13 = new KeysetEntity(13, 1, 0);
            KeysetEntity k14 = new KeysetEntity(14, 1, 1);
            KeysetEntity k15 = new KeysetEntity(15, 1, 1);
            KeysetEntity k16 = new KeysetEntity(16, 1, 2);
            KeysetEntity k17 = new KeysetEntity(17, 2, 1);
            KeysetEntity k18 = new KeysetEntity(18, 2, 2);
            em.persist(k01);
            em.persist(k02);
            em.persist(k03);
            em.persist(k04);
            em.persist(k05);
            em.persist(k06);
            em.persist(k07);
            em.persist(k08);
            em.persist(k09);
            em.persist(k10);
            em.persist(k11);
            em.persist(k12);
            em.persist(k13);
            em.persist(k14);
            em.persist(k15);
            em.persist(k16);
            em.persist(k17);
            em.persist(k18);
        }
    });
}
Also used : KeysetEntity(com.blazebit.persistence.testsuite.entity.KeysetEntity) EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork)

Example 95 with TxVoidWork

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

the class SubqueryTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            Document doc1 = new Document("doc1");
            Document doc2 = new Document("Doc2");
            Document doc3 = new Document("doC3");
            Document doc4 = new Document("dOc4");
            Document doc5 = new Document("DOC5");
            Document doc6 = new Document("bdoc");
            Document doc7 = new Document("adoc");
            Person o1 = new Person("Karl1");
            Person o2 = new Person("Karl2");
            o1.getLocalized().put(1, "abra kadabra");
            o2.getLocalized().put(1, "ass");
            doc1.setOwner(o1);
            doc2.setOwner(o1);
            doc3.setOwner(o1);
            doc4.setOwner(o2);
            doc5.setOwner(o2);
            doc6.setOwner(o2);
            doc7.setOwner(o2);
            doc1.getContacts().put(1, o1);
            doc1.getContacts().put(2, o2);
            em.persist(o1);
            em.persist(o2);
            em.persist(doc1);
            em.persist(doc2);
            em.persist(doc3);
            em.persist(doc4);
            em.persist(doc5);
            em.persist(doc6);
            em.persist(doc7);
        }
    });
}
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