use of org.apache.cayenne.testdo.map_to_many.MapToMany in project cayenne by apache.
the class CDOMapRelationshipIT method testModifyToManyKey.
@Test
public void testModifyToManyKey() throws Exception {
createTestDataSet();
MapToMany o1 = Cayenne.objectForPK(context, MapToMany.class, 1);
Map targets = o1.getTargets();
MapToManyTarget target = (MapToManyTarget) targets.get("B");
target.setName("B1");
o1.getObjectContext().commitChanges();
assertNull(o1.getTargets().get("B"));
assertSame(target, o1.getTargets().get("B1"));
}
use of org.apache.cayenne.testdo.map_to_many.MapToMany in project cayenne by apache.
the class CDOMapRelationshipIT method testReadToMany.
@Test
public void testReadToMany() throws Exception {
createTestDataSet();
MapToMany o1 = Cayenne.objectForPK(context, MapToMany.class, 1);
Map targets = o1.getTargets();
assertTrue(((ValueHolder) targets).isFault());
assertNotNull(targets);
assertEquals(3, targets.size());
assertNotNull(targets.get("A"));
assertNotNull(targets.get("B"));
assertNotNull(targets.get("C"));
assertEquals(1, Cayenne.intPKForObject((Persistent) targets.get("A")));
assertEquals(2, Cayenne.intPKForObject((Persistent) targets.get("B")));
assertEquals(3, Cayenne.intPKForObject((Persistent) targets.get("C")));
}
use of org.apache.cayenne.testdo.map_to_many.MapToMany in project cayenne by apache.
the class CDOMapRelationshipIT method testReadToManyPrefetching.
@Test
public void testReadToManyPrefetching() throws Exception {
createTestDataSet();
SelectQuery query = new SelectQuery(MapToMany.class, ExpressionFactory.matchDbExp(MapToMany.ID_PK_COLUMN, new Integer(1)));
query.addPrefetch(MapToMany.TARGETS.disjoint());
MapToMany o1 = (MapToMany) Cayenne.objectForQuery(context, query);
Map targets = o1.getTargets();
assertFalse(((ValueHolder) targets).isFault());
assertNotNull(targets);
assertEquals(3, targets.size());
assertNotNull(targets.get("A"));
assertNotNull(targets.get("B"));
assertNotNull(targets.get("C"));
}
Aggregations