use of org.apache.cayenne.testdo.embeddable.EmbedEntity1 in project cayenne by apache.
the class EmbeddingIT method testUpdateEmbedded.
@Test
public void testUpdateEmbedded() throws Exception {
createUpdateDataSet();
List<EmbedEntity1> results = ObjectSelect.query(EmbedEntity1.class).orderBy(EmbedEntity1.NAME.asc()).select(context);
EmbedEntity1 o1 = results.get(0);
Embeddable1 e11 = new Embeddable1();
e11.setEmbedded10("x1");
e11.setEmbedded20("x2");
o1.setEmbedded1(e11);
assertEquals(PersistenceState.MODIFIED, o1.getPersistenceState());
context.commitChanges();
DataRow row = ObjectSelect.dataRowQuery(EmbedEntity1.class).selectOne(context);
assertNotNull(row);
assertEquals("x1", row.get("EMBEDDED10"));
}
use of org.apache.cayenne.testdo.embeddable.EmbedEntity1 in project cayenne by apache.
the class EmbeddingIT method testUpdateEmbeddedProperties.
@Test
public void testUpdateEmbeddedProperties() throws Exception {
createUpdateDataSet();
List<EmbedEntity1> results = ObjectSelect.query(EmbedEntity1.class).orderBy(EmbedEntity1.NAME.asc()).select(context);
EmbedEntity1 o1 = results.get(0);
Embeddable1 e11 = o1.getEmbedded1();
e11.setEmbedded10("x1");
assertEquals(PersistenceState.MODIFIED, o1.getPersistenceState());
context.commitChanges();
DataRow row = ObjectSelect.dataRowQuery(EmbedEntity1.class).selectOne(context);
assertNotNull(row);
assertEquals("x1", row.get("EMBEDDED10"));
}
use of org.apache.cayenne.testdo.embeddable.EmbedEntity1 in project cayenne by apache.
the class EmbeddingSerializeIT method testSerializationEntityWithEmbeddableCommited.
@Test
public void testSerializationEntityWithEmbeddableCommited() throws Exception {
createSelectDataSet();
ObjectSelect<EmbedEntity1> query = ObjectSelect.query(EmbedEntity1.class);
List<EmbedEntity1> results = query.select(context);
assertEquals(1, results.size());
EmbedEntity1 o1 = results.get(0);
assertNotNull(o1);
EmbedEntity1 o2 = Util.cloneViaSerialization(o1);
assertNotNull(o2);
assertEquals(o1.getPersistenceState(), PersistenceState.COMMITTED);
assertEquals(o2.getPersistenceState(), PersistenceState.HOLLOW);
assertEquals("e1", o1.getEmbedded1().getEmbedded10());
assertEquals("e3", o1.getEmbedded2().getEmbedded10());
assertNull(o2.getEmbedded1());
assertNull(o2.getEmbedded2());
}
use of org.apache.cayenne.testdo.embeddable.EmbedEntity1 in project cayenne by apache.
the class EmbeddingSerializeIT method testSerializationEmbeddable.
@Test
public void testSerializationEmbeddable() throws Exception {
createSelectDataSet();
ObjectSelect<EmbedEntity1> query = ObjectSelect.query(EmbedEntity1.class);
List<EmbedEntity1> results = query.select(context);
assertEquals(1, results.size());
EmbedEntity1 o1 = results.get(0);
assertNotNull(o1);
Embeddable1 e1 = o1.getEmbedded1();
Embeddable1 e2 = Util.cloneViaSerialization(e1);
assertEquals(e1.getEmbedded10(), e2.getEmbedded10());
}
use of org.apache.cayenne.testdo.embeddable.EmbedEntity1 in project cayenne by apache.
the class EmbeddingSerializeIT method testSerializationEntityWithEmbeddableModified.
@Test
public void testSerializationEntityWithEmbeddableModified() throws Exception {
createSelectDataSet();
ObjectSelect<EmbedEntity1> query = ObjectSelect.query(EmbedEntity1.class);
List<EmbedEntity1> results = query.select(context);
assertEquals(1, results.size());
EmbedEntity1 o1 = results.get(0);
assertNotNull(o1);
o1.setPersistenceState(PersistenceState.MODIFIED);
EmbedEntity1 o2 = Util.cloneViaSerialization(o1);
assertNotNull(o2);
assertEquals(o1.getPersistenceState(), PersistenceState.MODIFIED);
assertEquals(o2.getPersistenceState(), PersistenceState.MODIFIED);
assertEquals("e1", o1.getEmbedded1().getEmbedded10());
assertEquals("e1", o2.getEmbedded1().getEmbedded10());
assertEquals("e3", o1.getEmbedded2().getEmbedded10());
assertEquals("e3", o2.getEmbedded2().getEmbedded10());
}
Aggregations