Search in sources :

Example 1 with PolymorphicSub1

use of com.blazebit.persistence.testsuite.entity.PolymorphicSub1 in project blaze-persistence by Blazebit.

the class UpdatePolymorphicTest method setUp.

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

        @Override
        public void work(EntityManager em) {
            // Table per class data
            TPCSub1 tpc1 = new TPCSub1(1L, "TPC1");
            TPCSub2 tpc2 = new TPCSub2(2L, "TPC2");
            em.persist(tpc1);
            em.persist(tpc2);
            // Joined data
            PolymorphicSub1 joined1 = new PolymorphicSub1();
            PolymorphicSub2 joined2 = new PolymorphicSub2();
            joined1.setName("JOINED1");
            joined2.setName("JOINED2");
            em.persist(joined1);
            em.persist(joined2);
            // Single table data
            PolymorphicPropertySub1 st1 = new PolymorphicPropertySub1();
            PolymorphicPropertySub2 st2 = new PolymorphicPropertySub2();
            st1.setName("ST1");
            st2.setName("ST2");
            em.persist(st1);
            em.persist(st2);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) PolymorphicPropertySub1(com.blazebit.persistence.testsuite.entity.PolymorphicPropertySub1) PolymorphicPropertySub2(com.blazebit.persistence.testsuite.entity.PolymorphicPropertySub2) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) PolymorphicSub2(com.blazebit.persistence.testsuite.entity.PolymorphicSub2) PolymorphicSub1(com.blazebit.persistence.testsuite.entity.PolymorphicSub1) TPCSub1(com.blazebit.persistence.testsuite.entity.TPCSub1) TPCSub2(com.blazebit.persistence.testsuite.entity.TPCSub2) Before(org.junit.Before)

Example 2 with PolymorphicSub1

use of com.blazebit.persistence.testsuite.entity.PolymorphicSub1 in project blaze-persistence by Blazebit.

the class TreatedCorrelatedSubqueryTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            PolymorphicSub1 root1 = new PolymorphicSub1();
            PolymorphicSub1 parent1 = new PolymorphicSub1();
            root2 = new PolymorphicSub1();
            PolymorphicSub2 parent2 = new PolymorphicSub2();
            root1.setSub1Value(1);
            root1.setParent(parent1);
            root2.setSub1Value(2);
            root2.setParent(parent2);
            em.persist(parent1);
            em.persist(parent2);
            em.persist(root1);
            em.persist(root2);
            parent2.setParent2(root1);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) PolymorphicSub2(com.blazebit.persistence.testsuite.entity.PolymorphicSub2) PolymorphicSub1(com.blazebit.persistence.testsuite.entity.PolymorphicSub1)

Example 3 with PolymorphicSub1

use of com.blazebit.persistence.testsuite.entity.PolymorphicSub1 in project blaze-persistence by Blazebit.

the class TreatedEntityJoinTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            PolymorphicSub1 root1 = new PolymorphicSub1();
            PolymorphicSub1 parent1 = new PolymorphicSub1();
            root2 = new PolymorphicSub1();
            PolymorphicSub2 parent2 = new PolymorphicSub2();
            root1.setSub1Value(1);
            root1.setParent(parent1);
            root2.setSub1Value(2);
            root2.setParent(parent2);
            em.persist(parent1);
            em.persist(parent2);
            em.persist(root1);
            em.persist(root2);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) PolymorphicSub2(com.blazebit.persistence.testsuite.entity.PolymorphicSub2) PolymorphicSub1(com.blazebit.persistence.testsuite.entity.PolymorphicSub1)

Example 4 with PolymorphicSub1

use of com.blazebit.persistence.testsuite.entity.PolymorphicSub1 in project blaze-persistence by Blazebit.

the class DeletePolymorphicTest method setUp.

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

        @Override
        public void work(EntityManager em) {
            // Table per class data
            tpc1 = new TPCSub1(1L, "TPC1");
            tpc2 = new TPCSub2(2L, "TPC2");
            em.persist(tpc1);
            em.persist(tpc2);
            // Joined data
            joined1 = new PolymorphicSub1();
            joined2 = new PolymorphicSub2();
            joined1.setName("JOINED1");
            joined2.setName("JOINED2");
            em.persist(joined1);
            em.persist(joined2);
            // Single table data
            st1 = new PolymorphicPropertySub1();
            st2 = new PolymorphicPropertySub2();
            st1.setName("ST1");
            st2.setName("ST2");
            em.persist(st1);
            em.persist(st2);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) PolymorphicPropertySub1(com.blazebit.persistence.testsuite.entity.PolymorphicPropertySub1) PolymorphicPropertySub2(com.blazebit.persistence.testsuite.entity.PolymorphicPropertySub2) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) PolymorphicSub2(com.blazebit.persistence.testsuite.entity.PolymorphicSub2) PolymorphicSub1(com.blazebit.persistence.testsuite.entity.PolymorphicSub1) TPCSub1(com.blazebit.persistence.testsuite.entity.TPCSub1) TPCSub2(com.blazebit.persistence.testsuite.entity.TPCSub2) Before(org.junit.Before)

Aggregations

PolymorphicSub1 (com.blazebit.persistence.testsuite.entity.PolymorphicSub1)4 PolymorphicSub2 (com.blazebit.persistence.testsuite.entity.PolymorphicSub2)4 TxVoidWork (com.blazebit.persistence.testsuite.tx.TxVoidWork)4 EntityManager (javax.persistence.EntityManager)4 PolymorphicPropertySub1 (com.blazebit.persistence.testsuite.entity.PolymorphicPropertySub1)2 PolymorphicPropertySub2 (com.blazebit.persistence.testsuite.entity.PolymorphicPropertySub2)2 TPCSub1 (com.blazebit.persistence.testsuite.entity.TPCSub1)2 TPCSub2 (com.blazebit.persistence.testsuite.entity.TPCSub2)2 Before (org.junit.Before)2