Search in sources :

Example 1 with Sub2

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

the class AbstractTreatVariationsTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            IntIdEntity i1 = new IntIdEntity("i1", 1);
            em.persist(i1);
            persist(em, new IntIdEntity("s1", 1));
            persist(em, new IntIdEntity("s2", 2));
            persist(em, new IntIdEntity("s1.parent", 101));
            persist(em, new IntIdEntity("s2.parent", 102));
            persist(em, new IntIdEntity("st1", 1));
            persist(em, new IntIdEntity("st2", 2));
            persist(em, new IntIdEntity("st1.parent", 101));
            persist(em, new IntIdEntity("st2.parent", 102));
            persist(em, new IntIdEntity("tpc1", 1));
            persist(em, new IntIdEntity("tpc2", 2));
            persist(em, new IntIdEntity("tpc1.parent", 101));
            persist(em, new IntIdEntity("tpc2.parent", 102));
            /**
             **************
             * Joined
             **************
             */
            JoinedSub1 s1 = new JoinedSub1("s1");
            JoinedSub2 s2 = new JoinedSub2("s2");
            JoinedSub1 s1Parent = new JoinedSub1("s1.parent");
            JoinedSub2 s2Parent = new JoinedSub2("s2.parent");
            persist(em, i1, s1, s2, s1Parent, s2Parent);
            /**
             **************
             * Single Table
             **************
             */
            SingleTableSub1 st1 = new SingleTableSub1("st1");
            SingleTableSub2 st2 = new SingleTableSub2("st2");
            SingleTableSub1 st1Parent = new SingleTableSub1("st1.parent");
            SingleTableSub2 st2Parent = new SingleTableSub2("st2.parent");
            persist(em, i1, st1, st2, st1Parent, st2Parent);
            /**
             **************
             * Table per Class
             **************
             */
            TablePerClassSub1 tpc1 = new TablePerClassSub1(1L, "tpc1");
            TablePerClassSub2 tpc2 = new TablePerClassSub2(2L, "tpc2");
            TablePerClassSub1 tpc1Parent = new TablePerClassSub1(3L, "tpc1.parent");
            TablePerClassSub2 tpc2Parent = new TablePerClassSub2(4L, "tpc2.parent");
            // The Java compiler can't up-cast automatically, maybe a bug?
            // persist(em, i1, tpc1, tpc2, tpc1Parent, tpc2Parent);
            persist(em, i1, (Sub1) tpc1, (Sub2) tpc2, (Sub1) tpc1Parent, (Sub2) tpc2Parent);
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) IntIdEntity(com.blazebit.persistence.testsuite.entity.IntIdEntity) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) JoinedSub2(com.blazebit.persistence.testsuite.treat.entity.JoinedSub2) TablePerClassSub2(com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub2) Sub2(com.blazebit.persistence.testsuite.treat.entity.Sub2) SingleTableSub2(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub2) SingleTableSub1(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub1) JoinedSub1(com.blazebit.persistence.testsuite.treat.entity.JoinedSub1) TablePerClassSub1(com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub1) Sub1(com.blazebit.persistence.testsuite.treat.entity.Sub1) SingleTableSub1(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub1) TablePerClassSub2(com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub2) SingleTableSub2(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub2) TablePerClassSub1(com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub1) JoinedSub2(com.blazebit.persistence.testsuite.treat.entity.JoinedSub2) JoinedSub1(com.blazebit.persistence.testsuite.treat.entity.JoinedSub1)

Example 2 with Sub2

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

the class AbstractTreatVariationsTest method setUpOnce.

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

        @Override
        public void work(EntityManager em) {
            IntIdEntity i1 = new IntIdEntity("i1", 1);
            em.persist(i1);
            persist(em, new IntIdEntity("s1", 1));
            persist(em, new IntIdEntity("s2", 2));
            persist(em, new IntIdEntity("s1.parent", 101));
            persist(em, new IntIdEntity("s2.parent", 102));
            persist(em, new IntIdEntity("st1", 1));
            persist(em, new IntIdEntity("st2", 2));
            persist(em, new IntIdEntity("st1.parent", 101));
            persist(em, new IntIdEntity("st2.parent", 102));
            persist(em, new IntIdEntity("tpc1", 1));
            persist(em, new IntIdEntity("tpc2", 2));
            persist(em, new IntIdEntity("tpc1.parent", 101));
            persist(em, new IntIdEntity("tpc2.parent", 102));
            /**
             **************
             * Joined
             **************
             */
            JoinedSub1 s1 = new JoinedSub1("s1");
            JoinedSub2 s2 = new JoinedSub2("s2");
            JoinedSub1 s1Parent = new JoinedSub1("s1.parent");
            JoinedSub2 s2Parent = new JoinedSub2("s2.parent");
            if (supportsJoinedInheritance()) {
                persist(em, i1, s1, s2, s1Parent, s2Parent);
            }
            /**
             **************
             * Single Table
             **************
             */
            SingleTableSub1 st1 = new SingleTableSub1("st1");
            SingleTableSub2 st2 = new SingleTableSub2("st2");
            SingleTableSub1 st1Parent = new SingleTableSub1("st1.parent");
            SingleTableSub2 st2Parent = new SingleTableSub2("st2.parent");
            persist(em, i1, st1, st2, st1Parent, st2Parent);
            /**
             **************
             * Table per Class
             **************
             */
            TablePerClassSub1 tpc1 = new TablePerClassSub1(1L, "tpc1");
            TablePerClassSub2 tpc2 = new TablePerClassSub2(2L, "tpc2");
            TablePerClassSub1 tpc1Parent = new TablePerClassSub1(3L, "tpc1.parent");
            TablePerClassSub2 tpc2Parent = new TablePerClassSub2(4L, "tpc2.parent");
            // persist(em, i1, tpc1, tpc2, tpc1Parent, tpc2Parent);
            if (supportsTablePerClassInheritance()) {
                persist(em, i1, (Sub1) tpc1, (Sub2) tpc2, (Sub1) tpc1Parent, (Sub2) tpc2Parent);
            }
        }
    });
}
Also used : EntityManager(javax.persistence.EntityManager) IntIdEntity(com.blazebit.persistence.testsuite.entity.IntIdEntity) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) JoinedSub2(com.blazebit.persistence.testsuite.treat.entity.JoinedSub2) TablePerClassSub2(com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub2) Sub2(com.blazebit.persistence.testsuite.treat.entity.Sub2) SingleTableSub2(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub2) SingleTableSub1(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub1) JoinedSub1(com.blazebit.persistence.testsuite.treat.entity.JoinedSub1) TablePerClassSub1(com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub1) Sub1(com.blazebit.persistence.testsuite.treat.entity.Sub1) SingleTableSub1(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub1) TablePerClassSub2(com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub2) SingleTableSub2(com.blazebit.persistence.testsuite.treat.entity.SingleTableSub2) TablePerClassSub1(com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub1) JoinedSub2(com.blazebit.persistence.testsuite.treat.entity.JoinedSub2) JoinedSub1(com.blazebit.persistence.testsuite.treat.entity.JoinedSub1)

Aggregations

IntIdEntity (com.blazebit.persistence.testsuite.entity.IntIdEntity)2 JoinedSub1 (com.blazebit.persistence.testsuite.treat.entity.JoinedSub1)2 JoinedSub2 (com.blazebit.persistence.testsuite.treat.entity.JoinedSub2)2 SingleTableSub1 (com.blazebit.persistence.testsuite.treat.entity.SingleTableSub1)2 SingleTableSub2 (com.blazebit.persistence.testsuite.treat.entity.SingleTableSub2)2 Sub1 (com.blazebit.persistence.testsuite.treat.entity.Sub1)2 Sub2 (com.blazebit.persistence.testsuite.treat.entity.Sub2)2 TablePerClassSub1 (com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub1)2 TablePerClassSub2 (com.blazebit.persistence.testsuite.treat.entity.TablePerClassSub2)2 TxVoidWork (com.blazebit.persistence.testsuite.tx.TxVoidWork)2 EntityManager (javax.persistence.EntityManager)2