Search in sources :

Example 26 with TxVoidWork

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

the class LimitTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            Person o1 = new Person("pers1");
            Document doc1 = new Document("doc1", o1);
            doc1.setAge(10);
            Document doc2 = new Document("doc2", o1);
            doc2.setAge(5);
            Document doc3 = new Document("doc3", o1);
            doc3.setAge(10);
            em.persist(o1);
            em.persist(doc1);
            em.persist(doc2);
            em.persist(doc3);
        }
    });
}
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 27 with TxVoidWork

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

the class EntityViewUpdateSubviewInverseEmbeddedSimpleTest method testLoadMultipleUpdatableWithUpdatableFlatViewIds.

@Test
public void testLoadMultipleUpdatableWithUpdatableFlatViewIds() {
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            LegacyOrder o = new LegacyOrder();
            em.persist(o);
            LegacyOrderPosition p = new LegacyOrderPosition(new LegacyOrderPositionId(o.getId(), 0));
            p.setArticleNumber("123");
            p.setOrder(o);
            em.persist(p);
            o.getPositions().add(p);
            LegacyOrderPositionDefault d1 = new LegacyOrderPositionDefault(new LegacyOrderPositionDefaultId(p.getId(), 1));
            d1.setValue("1");
            em.persist(d1);
            LegacyOrderPositionDefault d2 = new LegacyOrderPositionDefault(new LegacyOrderPositionDefaultId(p.getId(), 2));
            d2.setValue("1");
            em.persist(d2);
            p.getDefaults().add(d1);
            p.getDefaults().add(d2);
        }
    });
    em.clear();
    List<UpdatableLegacyOrderPositionDefaultView> resultList = evm.applySetting(EntityViewSetting.create(UpdatableLegacyOrderPositionDefaultView.class), cbf.create(em, LegacyOrderPositionDefault.class)).getResultList();
    // Making the id view updatable at some point caused just a part of the id to be considered when de-duplicating updatable views
    assertEquals(2, resultList.size());
    assertNotEquals(resultList.get(0).getId(), resultList.get(1).getId());
}
Also used : LegacyOrderPosition(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPosition) EntityManager(javax.persistence.EntityManager) UpdatableLegacyOrderPositionDefaultView(com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.simple.model.UpdatableLegacyOrderPositionDefaultView) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) LegacyOrderPositionDefault(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionDefault) LegacyOrderPositionId(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionId) LegacyOrderPositionDefaultId(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionDefaultId) LegacyOrder(com.blazebit.persistence.view.testsuite.entity.LegacyOrder) AbstractEntityViewUpdateTest(com.blazebit.persistence.view.testsuite.update.AbstractEntityViewUpdateTest) Test(org.junit.Test)

Example 28 with TxVoidWork

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

the class ListaggTest 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();
            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("a");
            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 29 with TxVoidWork

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

the class CollectionRoleDeleteTest method setUp.

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

        @Override
        public void work(EntityManager em) {
            Root r = new Root(1, "r");
            IndexedNode i1 = new IndexedNode(2, r);
            KeyedNode k1 = new KeyedNode(3, r);
            r.getIndexedNodes().add(i1);
            r.getIndexedNodesMany().add(i1);
            r.getIndexedNodesManyDuplicate().add(i1);
            r.getIndexedNodesElementCollection().add(new IndexedEmbeddable("a", "b"));
            r.getKeyedNodes().put("a", k1);
            r.getKeyedNodesMany().put("a", k1);
            r.getKeyedNodesManyDuplicate().put("a", k1);
            r.getKeyedNodesElementCollection().put("a", new KeyedEmbeddable("a", "b"));
            em.persist(i1);
            em.persist(k1);
            em.persist(r);
        }
    });
}
Also used : IndexedNode(com.blazebit.persistence.testsuite.entity.IndexedNode) EntityManager(javax.persistence.EntityManager) IndexedEmbeddable(com.blazebit.persistence.testsuite.entity.IndexedEmbeddable) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) Root(com.blazebit.persistence.testsuite.entity.Root) KeyedNode(com.blazebit.persistence.testsuite.entity.KeyedNode) KeyedEmbeddable(com.blazebit.persistence.testsuite.entity.KeyedEmbeddable) Before(org.junit.Before)

Example 30 with TxVoidWork

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

the class CollectionRoleInsertTest method setUp.

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

        @Override
        public void work(EntityManager em) {
            Root r = new Root(1);
            IndexedNode i1 = new IndexedNode(2);
            KeyedNode k1 = new KeyedNode(3);
            r.getIndexedNodes().add(i1);
            r.getIndexedNodesMany().add(i1);
            r.getIndexedNodesManyDuplicate().add(i1);
            r.getIndexedNodesElementCollection().add(new IndexedEmbeddable("a", "b"));
            r.getKeyedNodes().put("a", k1);
            r.getKeyedNodesMany().put("a", k1);
            r.getKeyedNodesManyDuplicate().put("a", k1);
            r.getKeyedNodesElementCollection().put("a", new KeyedEmbeddable("a", "b"));
            em.persist(i1);
            em.persist(k1);
            em.persist(r);
            IndexedNode i2 = new IndexedNode(I2_ID);
            em.persist(i2);
            KeyedNode k2 = new KeyedNode(K2_ID);
            em.persist(k2);
        }
    });
}
Also used : IndexedNode(com.blazebit.persistence.testsuite.entity.IndexedNode) EntityManager(javax.persistence.EntityManager) IndexedEmbeddable(com.blazebit.persistence.testsuite.entity.IndexedEmbeddable) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) Root(com.blazebit.persistence.testsuite.entity.Root) KeyedNode(com.blazebit.persistence.testsuite.entity.KeyedNode) KeyedEmbeddable(com.blazebit.persistence.testsuite.entity.KeyedEmbeddable) 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