use of com.blazebit.persistence.testsuite.entity.EmbeddableTestEntityId 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.EmbeddableTestEntityId 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.EmbeddableTestEntityId 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);
}
});
}
Aggregations