Search in sources :

Example 1 with PolymorphicPropertySub2

use of com.blazebit.persistence.testsuite.entity.PolymorphicPropertySub2 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 PolymorphicPropertySub2

use of com.blazebit.persistence.testsuite.entity.PolymorphicPropertySub2 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

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