Search in sources :

Example 66 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTExtractTest method testDayOfWeek.

@Test
public void testDayOfWeek() {
    String expStr = "dayOfWeek(dateColumn)";
    Expression expParsed = ExpressionFactory.exp(expStr);
    Expression expFromFactory = FunctionExpressionFactory.dayOfWeekExp("dateColumn");
    assertTrue(expParsed instanceof ASTExtract);
    assertTrue(expFromFactory instanceof ASTExtract);
    assertEquals(expStr, expParsed.toString());
    assertEquals(expStr, expFromFactory.toString());
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 67 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTExtractTest method testDay.

@Test
public void testDay() {
    String expStr = "day(dateColumn)";
    Expression expParsed = ExpressionFactory.exp(expStr);
    assertTrue(expParsed instanceof ASTExtract);
    assertEquals(expStr, expParsed.toString());
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 68 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTExtractTest method testMinute.

@Test
public void testMinute() {
    String expStr = "minute(dateColumn)";
    Expression expParsed = ExpressionFactory.exp(expStr);
    Expression expFromFactory = FunctionExpressionFactory.minuteExp("dateColumn");
    assertTrue(expParsed instanceof ASTExtract);
    assertTrue(expFromFactory instanceof ASTExtract);
    assertEquals(expStr, expParsed.toString());
    assertEquals(expStr, expFromFactory.toString());
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 69 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTExtractTest method testWeek.

@Test
public void testWeek() {
    String expStr = "week(dateColumn)";
    Expression expParsed = ExpressionFactory.exp(expStr);
    Expression expFromFactory = FunctionExpressionFactory.weekExp("dateColumn");
    assertTrue(expParsed instanceof ASTExtract);
    assertTrue(expFromFactory instanceof ASTExtract);
    assertEquals(expStr, expParsed.toString());
    assertEquals(expStr, expFromFactory.toString());
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 70 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTFunctionCallDateIT method testASTCurrentTimeParse.

@Test
public void testASTCurrentTimeParse() {
    Expression exp = ExpressionFactory.exp("timeColumn > currentTime()");
    DateTestEntity res = ObjectSelect.query(DateTestEntity.class, exp).selectOne(context);
    if (!unitDbAdapter.supportsTimeSqlType()) {
        return;
    }
    assertNotNull(res);
}
Also used : Expression(org.apache.cayenne.exp.Expression) DateTestEntity(org.apache.cayenne.testdo.date_time.DateTestEntity) Test(org.junit.Test)

Aggregations

Expression (org.apache.cayenne.exp.Expression)298 Test (org.junit.Test)265 Artist (org.apache.cayenne.testdo.testmap.Artist)69 SelectQuery (org.apache.cayenne.query.SelectQuery)47 Painting (org.apache.cayenne.testdo.testmap.Painting)29 BigDecimal (java.math.BigDecimal)23 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)17 DateTestEntity (org.apache.cayenne.testdo.date_time.DateTestEntity)16 ObjEntity (org.apache.cayenne.map.ObjEntity)13 ClientMtTable1 (org.apache.cayenne.testdo.mt.ClientMtTable1)12 DbEntity (org.apache.cayenne.map.DbEntity)10 List (java.util.List)9 HashMap (java.util.HashMap)8 DataRow (org.apache.cayenne.DataRow)8 DbAttribute (org.apache.cayenne.map.DbAttribute)8 ClientMtTable2 (org.apache.cayenne.testdo.mt.ClientMtTable2)7 DbRelationship (org.apache.cayenne.map.DbRelationship)6 ObjAttribute (org.apache.cayenne.map.ObjAttribute)6 ObjRelationship (org.apache.cayenne.map.ObjRelationship)6 Gallery (org.apache.cayenne.testdo.testmap.Gallery)6