use of com.blazebit.persistence.testsuite.entity.IntIdEntity 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();
}
use of com.blazebit.persistence.testsuite.entity.IntIdEntity in project blaze-persistence by Blazebit.
the class EmbeddedInheritanceTest method setUpOnce.
@Override
public void setUpOnce() {
cleanDatabase();
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
IntIdEntity i1 = new IntIdEntity("i1", 1);
base1 = new SingleTableSub1("st1");
base2 = new SingleTableSub2("st2");
base1.setSub1Value(123);
base2.setSub2Value(456);
base2.setRelation2(i1);
em.persist(i1);
em.persist(base1);
em.persist(base2);
base1.setParent(base2);
base2.setParent(base1);
}
});
}
use of com.blazebit.persistence.testsuite.entity.IntIdEntity 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);
}
});
}
use of com.blazebit.persistence.testsuite.entity.IntIdEntity in project blaze-persistence by Blazebit.
the class EntityViewUpdateMutableNestedEmbeddableMapsTest method assertSubviewEquals.
private void assertSubviewEquals(Map<String, IntIdEntity> entities, Map<String, SimpleIntIdEntityView> views) {
assertEquals(entities.size(), views.size());
Map<String, SimpleIntIdEntityView> unmatched = new HashMap<>(views);
for (Map.Entry<String, IntIdEntity> entry : entities.entrySet()) {
IntIdEntity value = entry.getValue();
SimpleIntIdEntityView view = unmatched.remove(entry.getKey());
if (view == null || !value.getId().equals(view.getId())) {
Assert.fail("Unmatched name object: " + value);
}
}
if (!unmatched.isEmpty()) {
Assert.fail("Unmatched views: " + unmatched);
}
}
use of com.blazebit.persistence.testsuite.entity.IntIdEntity in project blaze-persistence by Blazebit.
the class AbstractEntityViewUpdateNestedEmbeddableEntityTest method prepareData.
@Override
protected void prepareData(EntityManager em) {
entity1 = new EmbeddableTestEntity();
entity1.getId().setKey("e1");
entity1.getId().setValue("e1");
entity1.setVersion(1L);
entity2 = new EmbeddableTestEntity();
entity2.getId().setKey("e2");
entity2.getId().setValue("e2");
entity2.setVersion(1L);
intIdEntity1 = new IntIdEntity("i1", 1);
intIdEntity2 = new IntIdEntity("i2", 2);
em.persist(entity1);
em.persist(entity2);
em.persist(intIdEntity1);
em.persist(intIdEntity2);
entity1.getEmbeddable().setManyToOne(entity1);
entity1.getEmbeddable().getManyToMany().put("a", intIdEntity1);
entity1.getEmbeddable().getOneToMany2().add(entity1);
entity1.getEmbeddable().getElementCollection().put("a", new NameObject("a", "b", intIdEntity1));
entity1.getEmbeddable().getNestedEmbeddable().getNestedOneToMany().add(entity1);
}
Aggregations