use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class NestedCayenneContextIT method testQueriesOnTemporaryObject.
/**
* CAY1714
*/
@Test
public void testQueriesOnTemporaryObject() throws Exception {
ObjectContext clientContext = runtime.newContext((DataChannel) this.clientContext);
ClientMtTable1 parentMt = clientContext.newObject(ClientMtTable1.class);
ObjectContext childContext = runtime.newContext((DataChannel) clientContext);
ClientMtTable1 childMt = (ClientMtTable1) Cayenne.objectForPK(childContext, parentMt.getObjectId());
childMt.setGlobalAttribute1("1183");
ClientMtTable2 childMt2 = childContext.newObject(ClientMtTable2.class);
childMt2.setGlobalAttribute("1183");
childMt2.setTable1(childMt);
childContext.commitChangesToParent();
assertNull(childMt2.getTable3());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class PersistentObjectInContextIT method testToOneRelationship.
@Test
public void testToOneRelationship() throws Exception {
createTwoMtTable1sAnd2sDataSet();
ObjectId gid = new ObjectId("MtTable2", MtTable2.TABLE2_ID_PK_COLUMN, new Integer(1));
ClientMtTable2 mtTable21 = (ClientMtTable2) Cayenne.objectForQuery(context, new ObjectIdQuery(gid));
assertNotNull(mtTable21);
ClientMtTable1 mtTable1 = mtTable21.getTable1();
assertNotNull("To one relationship incorrectly resolved to null", mtTable1);
assertEquals("g1", mtTable1.getGlobalAttribute1());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class PersistentObjectInContextIT method testResolveToManyReverseResolved.
@Test
public void testResolveToManyReverseResolved() throws Exception {
createTwoMtTable1sAnd2sDataSet();
ObjectId gid = new ObjectId("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, new Integer(1));
ClientMtTable1 t1 = (ClientMtTable1) Cayenne.objectForQuery(context, new ObjectIdQuery(gid));
assertNotNull(t1);
List<ClientMtTable2> t2s = t1.getTable2Array();
assertEquals(2, t2s.size());
for (ClientMtTable2 t2 : t2s) {
PersistentObjectHolder holder = (PersistentObjectHolder) t2.getTable1Direct();
assertFalse(holder.isFault());
assertSame(t1, holder.getValue());
}
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientServerChannelIT method testGetEntityResolver.
@Test
public void testGetEntityResolver() throws Exception {
EntityResolver resolver = clientServerChannel.getEntityResolver();
assertNotNull(resolver);
assertNull(resolver.getObjEntity(ClientMtTable1.class));
assertNotNull(resolver.getClientEntityResolver().getObjEntity(ClientMtTable1.class));
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientServerChannelIT method testOnQueryPrefetchingToMany.
@Test
public void testOnQueryPrefetchingToMany() throws Exception {
createTwoMtTable1sAnd2sDataSet();
SelectQuery query = new SelectQuery(ClientMtTable1.class);
query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
query.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
final List<?> results = clientServerChannel.onQuery(null, query).firstList();
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
ClientMtTable1 o1 = (ClientMtTable1) results.get(0);
assertNull(o1.getObjectContext());
List<ClientMtTable2> children1 = o1.getTable2Array();
assertEquals(2, children1.size());
for (ClientMtTable2 o : children1) {
assertNull(o.getObjectContext());
}
}
});
}
Aggregations