use of org.apache.cayenne.testdo.mt.ClientMtTable2 in project cayenne by apache.
the class ClientExpressionIT method testExpressionFactoryMatchAny.
@Test
public void testExpressionFactoryMatchAny() throws Exception {
createDataSet();
SelectQuery<ClientMtTable2> table2Query = new SelectQuery<ClientMtTable2>(ClientMtTable2.class);
table2Query.addOrdering(new Ordering("db:TABLE2_ID", SortOrder.ASCENDING));
List<ClientMtTable2> table2List = context.select(table2Query);
ClientMtTable2 element_1 = table2List.get(0);
ClientMtTable2 element_2 = table2List.get(10);
Expression exp = ExpressionFactory.matchAnyExp(element_1, element_2);
table2Query = new SelectQuery<ClientMtTable2>(ClientMtTable2.class, exp);
table2List = context.select(table2Query);
assertEquals(2, table2List.size());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable2 in project cayenne by apache.
the class ClientExpressionIT method testExpressionFactoryBetween.
@Test
public void testExpressionFactoryBetween() 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_1 = table1List.get(0);
ClientMtTable1 element_7 = table1List.get(6);
// between
Expression exp = ExpressionFactory.betweenExp(ClientMtTable2.TABLE1_PROPERTY, element_1, element_7);
SelectQuery<ClientMtTable2> table2Query = new SelectQuery<ClientMtTable2>(ClientMtTable2.class, exp);
List<ClientMtTable2> table2List = context.select(table2Query);
assertEquals(14, table2List.size());
// not between
exp = ExpressionFactory.notBetweenExp(ClientMtTable2.TABLE1_PROPERTY, element_1, element_7);
table2Query = new SelectQuery<ClientMtTable2>(ClientMtTable2.class, exp);
table2List = context.select(table2Query);
assertEquals(6, table2List.size());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable2 in project cayenne by apache.
the class NestedObjectContextPeerEventsIT method testPeerObjectUpdatedToManyRelationship.
@Test
public void testPeerObjectUpdatedToManyRelationship() throws Exception {
ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class);
a.setGlobalAttribute1("X");
ClientMtTable2 px = clientContext.newObject(ClientMtTable2.class);
px.setTable1(a);
px.setGlobalAttribute("PX");
ClientMtTable2 py = clientContext.newObject(ClientMtTable2.class);
py.setGlobalAttribute("PY");
clientContext.commitChanges();
ObjectContext peer1 = runtime.newContext(clientContext);
ClientMtTable2 py1 = peer1.localObject(py);
ClientMtTable1 a1 = peer1.localObject(a);
ObjectContext peer2 = runtime.newContext(clientContext);
ClientMtTable2 py2 = peer2.localObject(py);
ClientMtTable1 a2 = peer2.localObject(a);
a1.addToTable2Array(py1);
assertEquals(1, a2.getTable2Array().size());
assertFalse(a2.getTable2Array().contains(py2));
peer1.commitChangesToParent();
assertEquals(2, a2.getTable2Array().size());
assertTrue(a2.getTable2Array().contains(py2));
assertFalse("Peer data context became dirty on event processing", peer2.hasChanges());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable2 in project cayenne by apache.
the class RelationshipChangeIT method testNullify.
@Test
public void testNullify() {
ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class);
ClientMtTable2 o2 = clientContext.newObject(ClientMtTable2.class);
o2.setTable1(o1);
assertEquals(1, o1.getTable2Array().size());
clientContext.commitChanges();
o2.setTable1(null);
assertEquals(0, o1.getTable2Array().size());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable2 in project cayenne by apache.
the class RemoteRollbackIT method testRollbackRelationshipModification.
@Test
public void testRollbackRelationshipModification() {
String o1Name = "relationshipModClientMtTable1";
String o2Title = "relationshipTestClientMtTable2";
ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class);
o1.setGlobalAttribute1(o1Name);
ClientMtTable2 o2 = clientContext.newObject(ClientMtTable2.class);
o2.setGlobalAttribute(o2Title);
o2.setTable1(o1);
assertEquals(1, o1.getTable2Array().size());
clientContext.commitChanges();
assertEquals(1, o1.getTable2Array().size());
o2.setTable1(null);
assertEquals(0, o1.getTable2Array().size());
clientContext.rollbackChanges();
assertEquals(1, o1.getTable2Array().size());
assertEquals(o1, o2.getTable1());
}
Aggregations