use of org.apache.cayenne.query.MappedSelect in project cayenne by apache.
the class CayenneContextNamedQueryCachingIT method testLocalCacheParameterized.
@Test
public void testLocalCacheParameterized() throws Exception {
createThreeMtTable1sDataSet();
final MappedSelect q1 = MappedSelect.query("ParameterizedMtQueryWithLocalCache").param("g", "g1");
final MappedSelect q2 = MappedSelect.query("ParameterizedMtQueryWithLocalCache").param("g", "g2");
final List<?> result1 = context.performQuery(q1);
assertEquals(1, result1.size());
clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
List<?> result2 = context.performQuery(q1);
assertSame(result1, result2);
}
});
final List<?> result3 = context.performQuery(q2);
assertNotSame(result1, result3);
assertEquals(1, result3.size());
clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
List<?> result4 = context.performQuery(q2);
assertSame(result3, result4);
List<?> result5 = context.performQuery(q1);
assertSame(result1, result5);
}
});
}
use of org.apache.cayenne.query.MappedSelect in project cayenne by apache.
the class CayenneContextNamedQueryCachingIT method testLocalCache.
@Test
public void testLocalCache() throws Exception {
createThreeMtTable1sDataSet();
final MappedSelect q1 = MappedSelect.query("MtQueryWithLocalCache");
final List<?> result1 = context.performQuery(q1);
assertEquals(3, result1.size());
clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
List<?> result2 = context.performQuery(q1);
assertSame(result1, result2);
}
});
// refresh
q1.forceNoCache();
List<?> result3 = context.performQuery(q1);
assertNotSame(result1, result3);
assertEquals(3, result3.size());
}
Aggregations