use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.
the class TablePerClassTest method setUpOnce.
@Override
public void setUpOnce() {
cleanDatabase();
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
TPCSub1 entity1 = new TPCSub1(1L, "test1");
TPCSub2 entity2 = new TPCSub2(2L, "test2");
em.persist(entity1);
em.persist(entity2);
}
});
}
use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.
the class TupleTest method testGetTupleElementAlias.
// from issue #490
@Test
public void testGetTupleElementAlias() {
cleanDatabase();
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
Document d = new Document("D1");
Person p1 = new Person("Joe");
Person p2 = new Person("Fred");
d.setOwner(p1);
d.getPartners().add(p1);
d.getPartners().add(p2);
em.persist(p1);
em.persist(p2);
em.persist(d);
}
});
CriteriaBuilder<Tuple> criteria = cbf.create(em, Tuple.class).from(Document.class, "d").select("d.id", "theId");
Tuple result = criteria.getResultList().get(0);
String alias = result.getElements().get(0).getAlias();
assertEquals("theId", alias);
assertEquals(result.get(0), result.get("theId"));
}
use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.
the class UpdateEmbeddableComplexTest method testUpdateWithReturningEmbeddable.
@Test
// TODO: report that datanucleus doesn't support element collection in an embeddable
@Category({ NoH2.class, NoOracle.class, NoSQLite.class, NoFirebird.class, NoMySQL.class, NoDatanucleus.class, NoEclipselink.class, NoOpenJPA.class })
public void testUpdateWithReturningEmbeddable() {
final String newEmbeddableTestEntityIdKey = "newKey";
cleanDatabase();
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
EmbeddableTestEntityId embeddable1Id = new EmbeddableTestEntityId("1", "oldKey");
EmbeddableTestEntity embeddable1 = new EmbeddableTestEntity();
embeddable1.setId(embeddable1Id);
em.persist(embeddable1);
em.flush();
String key = cbf.update(em, EmbeddableTestEntity.class, "e").set("id.key", newEmbeddableTestEntityIdKey).executeWithReturning("id.key", String.class).getLastResult();
assertEquals(newEmbeddableTestEntityIdKey, key);
}
});
}
use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.
the class OptimizedKeysetPaginationTest method setUpOnce.
@Override
public void setUpOnce() {
cleanDatabase();
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
DocumentWithNullableName doc1 = new DocumentWithNullableName("doc1");
DocumentWithNullableName doc2 = new DocumentWithNullableName("doc2");
DocumentWithNullableName doc3 = new DocumentWithNullableName("doc3");
DocumentWithNullableName doc4 = new DocumentWithNullableName("doc4");
DocumentWithNullableName doc5 = new DocumentWithNullableName("doc5");
DocumentWithNullableName doc6 = new DocumentWithNullableName("doc6");
Person o1 = new Person("Karl1");
Person o2 = new Person("Karl2");
Person o3 = new Person("Karl3");
o4 = new Person("Karl4");
doc1.setOwner(o1);
doc2.setOwner(o2);
doc3.setOwner(o3);
doc4.setOwner(o4);
doc5.setOwner(o4);
doc6.setOwner(o4);
doc1.setFriend(o1);
doc2.setFriend(o2);
doc3.setFriend(o3);
doc4.setFriend(o4);
doc5.setFriend(o4);
doc6.setFriend(o4);
em.persist(o1);
em.persist(o2);
em.persist(o3);
em.persist(o4);
em.persist(doc1);
em.persist(doc2);
em.persist(doc3);
em.persist(doc4);
em.persist(doc5);
em.persist(doc6);
}
});
}
use of com.blazebit.persistence.testsuite.tx.TxVoidWork in project blaze-persistence by Blazebit.
the class PaginationOneToOneTest method setUpOnce.
@Override
public void setUpOnce() {
cleanDatabase();
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
DocumentForOneToOne doc1 = new DocumentForOneToOne("doc1");
DocumentForOneToOne doc2 = new DocumentForOneToOne("doc2");
Person p1 = new Person("owner");
doc1.setOwner(p1);
doc2.setOwner(p1);
DocumentInfo o1 = new DocumentInfo(1L, doc2, "Karl1");
DocumentInfo o2 = new DocumentInfo(2L, doc1, "Karl2");
em.persist(p1);
em.persist(doc1);
em.persist(doc2);
em.persist(o1);
em.persist(o2);
}
});
}
Aggregations