use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ColumnSelectTest method and.
@Test
public void and() throws Exception {
ColumnSelect q = new ColumnSelect();
assertNull(q.getHaving());
assertNull(q.getWhere());
Expression expTrue = ExpressionFactory.expTrue();
q.where(expTrue);
q.and(expTrue);
assertNull(q.getHaving());
assertEquals(ExpressionFactory.exp("true and true"), q.getWhere());
Expression expFalse = ExpressionFactory.expFalse();
q.having("false");
q.and(expFalse);
assertEquals(ExpressionFactory.exp("false and false"), q.getHaving());
assertEquals(ExpressionFactory.exp("true and true"), q.getWhere());
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ColumnSelectTest method or.
@Test
public void or() throws Exception {
ColumnSelect q = new ColumnSelect();
assertNull(q.getHaving());
assertNull(q.getWhere());
Expression expTrue = ExpressionFactory.expTrue();
q.where(expTrue);
q.or(expTrue);
assertNull(q.getHaving());
assertEquals(ExpressionFactory.exp("true or true"), q.getWhere());
Expression expFalse = ExpressionFactory.expFalse();
q.having("false");
q.or(expFalse);
assertEquals(ExpressionFactory.exp("false or false"), q.getHaving());
assertEquals(ExpressionFactory.exp("true or true"), q.getWhere());
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ColumnSelectTest method havingExpression.
@Test
public void havingExpression() throws Exception {
ColumnSelect q = new ColumnSelect();
assertNull(q.getHaving());
assertNull(q.getWhere());
Expression expTrue = ExpressionFactory.expTrue();
q.where(expTrue);
assertNull(q.getHaving());
assertEquals(expTrue, q.getWhere());
Expression expFalse = ExpressionFactory.expFalse();
q.having(expFalse);
assertEquals(expFalse, q.getHaving());
assertEquals(expTrue, q.getWhere());
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ObjectSelect_RunIT method test_SelectFirst_SubstringInWhere.
@Test
public void test_SelectFirst_SubstringInWhere() throws Exception {
Expression exp = FunctionExpressionFactory.substringExp(Artist.ARTIST_NAME.path(), 2, 3);
Property<String> substrName = Property.create("substr", exp, String.class);
Artist a = ObjectSelect.query(Artist.class).where(substrName.eq("rti")).orderBy("db:ARTIST_ID").selectFirst(context);
assertNotNull(a);
assertEquals("artist1", a.getArtistName());
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class OrderingTest method testOrderingWithExpression.
@Test
public void testOrderingWithExpression() {
Expression exp = FunctionExpressionFactory.absExp("x");
Ordering ord = new Ordering();
ord.setSortSpec(exp);
ord.setSortOrder(SortOrder.ASCENDING);
Ordering ord2 = new Ordering(exp);
assertEquals(ord, ord2);
assertEquals(exp, ord2.getSortSpec());
assertEquals(SortOrder.ASCENDING, ord2.getSortOrder());
}
Aggregations