Search in sources :

Example 91 with ClientMtTable1

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());
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) ClientMtTable2(org.apache.cayenne.testdo.mt.ClientMtTable2) Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 92 with ClientMtTable1

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"));
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) Test(org.junit.Test)

Example 93 with ClientMtTable1

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);
        }
    });
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) UnitTestClosure(org.apache.cayenne.unit.di.UnitTestClosure) RemoteIncrementalFaultList(org.apache.cayenne.remote.RemoteIncrementalFaultList) List(java.util.List) Test(org.junit.Test)

Example 94 with ClientMtTable1

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);
        }
    });
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) UnitTestClosure(org.apache.cayenne.unit.di.UnitTestClosure) RemoteIncrementalFaultList(org.apache.cayenne.remote.RemoteIncrementalFaultList) List(java.util.List) Test(org.junit.Test)

Example 95 with ClientMtTable1

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());
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Aggregations

ClientMtTable1 (org.apache.cayenne.testdo.mt.ClientMtTable1)112 Test (org.junit.Test)112 ClientMtTable2 (org.apache.cayenne.testdo.mt.ClientMtTable2)46 SelectQuery (org.apache.cayenne.query.SelectQuery)26 UnitTestClosure (org.apache.cayenne.unit.di.UnitTestClosure)19 ObjectContext (org.apache.cayenne.ObjectContext)12 Expression (org.apache.cayenne.exp.Expression)12 ObjectIdQuery (org.apache.cayenne.query.ObjectIdQuery)11 List (java.util.List)8 ObjectId (org.apache.cayenne.ObjectId)7 EntityResolver (org.apache.cayenne.map.EntityResolver)7 LifecycleCallbackRegistry (org.apache.cayenne.reflect.LifecycleCallbackRegistry)7 RemoteIncrementalFaultList (org.apache.cayenne.remote.RemoteIncrementalFaultList)6 GraphDiff (org.apache.cayenne.graph.GraphDiff)5 MockEventManager (org.apache.cayenne.event.MockEventManager)4 ClientChannelServerDiffsListener1 (org.apache.cayenne.remote.ClientChannelServerDiffsListener1)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 GraphChangeHandler (org.apache.cayenne.graph.GraphChangeHandler)3 MtTable1 (org.apache.cayenne.testdo.mt.MtTable1)3