use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientExpressionIT method testExpressionFactoryOperators.
@Test
public void testExpressionFactoryOperators() throws Exception {
createDataSet();
SelectQuery<ClientMtTable1> table1Query = new SelectQuery<ClientMtTable1>(ClientMtTable1.class);
table1Query.addOrdering(new Ordering("db:TABLE1_ID", SortOrder.ASCENDING));
List<ClientMtTable1> table1List = context.select(table1Query);
ClientMtTable1 element_7 = table1List.get(6);
// greater than, ">"
Expression exp = ExpressionFactory.greaterExp(ClientMtTable2.TABLE1_PROPERTY, element_7);
SelectQuery<ClientMtTable2> table2Query = new SelectQuery<ClientMtTable2>(ClientMtTable2.class, exp);
List<ClientMtTable2> table2List = context.select(table2Query);
assertEquals(6, table2List.size());
// greater than or equal, ">="
exp = ExpressionFactory.greaterOrEqualExp(ClientMtTable2.TABLE1_PROPERTY, element_7);
table2Query = new SelectQuery<ClientMtTable2>(ClientMtTable2.class, exp);
table2List = context.select(table2Query);
assertEquals(8, table2List.size());
// less than, "<"
exp = ExpressionFactory.lessExp(ClientMtTable2.TABLE1_PROPERTY, element_7);
table2Query = new SelectQuery<ClientMtTable2>(ClientMtTable2.class, exp);
table2List = context.select(table2Query);
assertEquals(12, table2List.size());
// less than or equal, "<="
exp = ExpressionFactory.lessOrEqualExp(ClientMtTable2.TABLE1_PROPERTY, element_7);
table2Query = new SelectQuery<ClientMtTable2>(ClientMtTable2.class, exp);
table2List = context.select(table2Query);
assertEquals(14, table2List.size());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientObjectSelectIT method testCAY_2094.
@Test
public void testCAY_2094() {
ClientMtTable1 clientMtTable1 = SelectById.query(ClientMtTable1.class, 1).selectOne(context);
assertNotNull(clientMtTable1);
assertEquals(1, clientMtTable1.getObjectId().getIdSnapshot().get("TABLE1_ID"));
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientObjectSelectIT method testCacheLimitSelect.
@Test
public void testCacheLimitSelect() throws Exception {
final ObjectSelect<ClientMtTable1> objectSelect = ObjectSelect.query(ClientMtTable1.class).cacheStrategy(QueryCacheStrategy.SHARED_CACHE).offset(5).limit(10);
final List<ClientMtTable1> list1 = objectSelect.select(context);
assertEquals(10, list1.size());
serverCaseDataChannelInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
@Override
public void execute() {
List<ClientMtTable1> list2 = objectSelect.select(context);
assertNotNull(list2);
assertEquals(10, list2.size());
assertEquals(list1, list2);
}
});
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientObjectSelectIT method testCacheSelect.
@Test
public void testCacheSelect() throws Exception {
final ObjectSelect<ClientMtTable1> objectSelect = ObjectSelect.query(ClientMtTable1.class).cacheStrategy(QueryCacheStrategy.SHARED_CACHE);
final List<ClientMtTable1> list1 = objectSelect.select(context);
assertNotNull(list1);
assertFalse(list1.isEmpty());
serverCaseDataChannelInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
@Override
public void execute() {
List<ClientMtTable1> list2 = objectSelect.select(context);
assertNotNull(list2);
assertFalse(list2.isEmpty());
assertEquals(list1, list2);
}
});
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientSelectQueryExpressionIT method testDoubleSelectLikeExpression.
@Test
public void testDoubleSelectLikeExpression() throws Exception {
createMtTable1DataSet();
List<ClientMtTable1> mtTable1List = context.select(SelectQuery.query(ClientMtTable1.class));
Expression exp = ExpressionFactory.likeExp(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, "globalAttr1%");
exp.filterObjects(mtTable1List);
List<ClientMtTable1> matchingMtTableList = context.select(SelectQuery.query(ClientMtTable1.class, exp));
assertEquals(11, matchingMtTableList.size());
}
Aggregations