Search in sources :

Example 1 with EmbeddableTestEntityId2

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

the class EmbeddableTestEntityViewTest method setUp.

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

        @Override
        public void work(EntityManager em) {
            IntIdEntity intIdEntity1 = new IntIdEntity("1");
            entity1 = new EmbeddableTestEntity2();
            entity1.setId(new EmbeddableTestEntityId2(intIdEntity1, "1"));
            entity1.getEmbeddableSet().add(new EmbeddableTestEntitySimpleEmbeddable2("1"));
            entity1.getEmbeddableMap().put("key1", new EmbeddableTestEntitySimpleEmbeddable2("1"));
            entity1.getEmbeddable().setName("1");
            entity1.getEmbeddable().setManyToOne(null);
            entity1.getEmbeddable().getElementCollection().put("1", intIdEntity1);
            IntIdEntity intIdEntity2 = new IntIdEntity("2");
            entity2 = new EmbeddableTestEntity2();
            entity2.setId(new EmbeddableTestEntityId2(intIdEntity2, "2"));
            entity2.getEmbeddableSet().add(new EmbeddableTestEntitySimpleEmbeddable2("2"));
            entity2.getEmbeddableMap().put("key2", new EmbeddableTestEntitySimpleEmbeddable2("2"));
            entity2.getEmbeddable().setName("2");
            entity2.getEmbeddable().setManyToOne(entity1);
            entity2.getEmbeddable().getElementCollection().put("2", intIdEntity2);
            em.persist(intIdEntity1);
            em.persist(intIdEntity2);
            em.persist(entity1);
            em.persist(entity2);
        }
    });
    entity1 = cbf.create(em, EmbeddableTestEntity2.class).fetch("id.intIdEntity", "embeddableSet", "embeddableMap", "embeddable.manyToOne", "embeddable.oneToMany", "embeddable.elementCollection").where("id").eq(entity1.getId()).getSingleResult();
    entity2 = cbf.create(em, EmbeddableTestEntity2.class).fetch("id.intIdEntity", "embeddableSet", "embeddableMap", "embeddable.manyToOne", "embeddable.oneToMany", "embeddable.elementCollection").where("id").eq(entity2.getId()).getSingleResult();
}
Also used : EmbeddableTestEntity2(com.blazebit.persistence.view.testsuite.entity.EmbeddableTestEntity2) EmbeddableTestEntitySimpleEmbeddable2(com.blazebit.persistence.view.testsuite.entity.EmbeddableTestEntitySimpleEmbeddable2) EntityManager(javax.persistence.EntityManager) IntIdEntity(com.blazebit.persistence.testsuite.entity.IntIdEntity) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) EmbeddableTestEntityId2(com.blazebit.persistence.view.testsuite.entity.EmbeddableTestEntityId2) Before(org.junit.Before)

Aggregations

IntIdEntity (com.blazebit.persistence.testsuite.entity.IntIdEntity)1 TxVoidWork (com.blazebit.persistence.testsuite.tx.TxVoidWork)1 EmbeddableTestEntity2 (com.blazebit.persistence.view.testsuite.entity.EmbeddableTestEntity2)1 EmbeddableTestEntityId2 (com.blazebit.persistence.view.testsuite.entity.EmbeddableTestEntityId2)1 EmbeddableTestEntitySimpleEmbeddable2 (com.blazebit.persistence.view.testsuite.entity.EmbeddableTestEntitySimpleEmbeddable2)1 EntityManager (javax.persistence.EntityManager)1 Before (org.junit.Before)1