use of com.blazebit.persistence.testsuite.entity.EmbeddableTestEntity in project blaze-persistence by Blazebit.
the class UpdateEmbeddableComplexTest method testUpdateWithReturningExplicitId.
@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 testUpdateWithReturningExplicitId() {
final String intIdEntity1Key = "1";
cleanDatabase();
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
EmbeddableTestEntityId embeddable2Id = new EmbeddableTestEntityId("1", "2");
EmbeddableTestEntity embeddable2 = new EmbeddableTestEntity();
embeddable2.setId(embeddable2Id);
em.persist(embeddable2);
EmbeddableTestEntityId embeddable1Id = new EmbeddableTestEntityId("1", intIdEntity1Key);
EmbeddableTestEntity embeddable1 = new EmbeddableTestEntity();
embeddable1.setId(embeddable1Id);
EmbeddableTestEntityEmbeddable embeddable1Embeddable = new EmbeddableTestEntityEmbeddable();
embeddable1Embeddable.setManyToOne(embeddable2);
embeddable1.setEmbeddable(embeddable1Embeddable);
em.persist(embeddable1);
em.flush();
EmbeddableTestEntityId manyToOneId = cbf.update(em, EmbeddableTestEntity.class, "e").set("id.key", "newKey").where("e.id.key").eq(intIdEntity1Key).executeWithReturning("embeddable.manyToOne.id", EmbeddableTestEntityId.class).getLastResult();
assertEquals(embeddable2Id, manyToOneId);
}
});
}
use of com.blazebit.persistence.testsuite.entity.EmbeddableTestEntity 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);
}
use of com.blazebit.persistence.testsuite.entity.EmbeddableTestEntity 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.entity.EmbeddableTestEntity in project blaze-persistence by Blazebit.
the class EmbeddedCorrelationTest method setUpOnce.
@Override
protected void setUpOnce() {
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);
}
});
}
use of com.blazebit.persistence.testsuite.entity.EmbeddableTestEntity in project blaze-persistence by Blazebit.
the class EmbeddedCorrelationTest method testEmbeddedCorrelation.
// For #556
@Test
// NOTE: Eclipselink and Datanucleus don't support the single valued id access optimization which causes a cyclic join dependency
@Category({ NoHibernate42.class, NoHibernate43.class, NoHibernate50.class, NoDatanucleus.class, NoOpenJPA.class, NoEclipselink.class })
public void testEmbeddedCorrelation() {
EntityViewManager evm = build(EmbeddableTestEntityCorrelationView.class, EmbeddableTestEntityCorrelationView.Id.class, EmbeddableTestEntityCorrelationView.SimpleEmbeddableTestEntityCorrelationView.class);
CriteriaBuilder<EmbeddableTestEntity> criteria = cbf.create(em, EmbeddableTestEntity.class, "d");
EntityViewSetting<EmbeddableTestEntityCorrelationView, CriteriaBuilder<EmbeddableTestEntityCorrelationView>> setting = EntityViewSetting.create(EmbeddableTestEntityCorrelationView.class);
CriteriaBuilder<EmbeddableTestEntityCorrelationView> cb = evm.applySetting(setting, criteria);
cb.getResultList();
}
Aggregations