Search in sources :

Example 16 with DateTestEntity

use of org.apache.cayenne.testdo.date_time.DateTestEntity in project cayenne by apache.

the class ASTFunctionCallDateIT method testCurrentTime.

@Test
public void testCurrentTime() throws Exception {
    Expression exp = ExpressionFactory.greaterOrEqualExp("timeColumn", new ASTCurrentTime());
    List<DateTestEntity> res = ObjectSelect.query(DateTestEntity.class, exp).select(context);
    if (!unitDbAdapter.supportsTimeSqlType()) {
        // result will be invalid most likely as DB doesn't support TIME data type
        return;
    }
    assertEquals(1, res.size());
    DateTestEntity res1 = res.get(0);
    Expression exp2 = ExpressionFactory.lessExp("timeColumn", new ASTCurrentTime());
    DateTestEntity res2 = ObjectSelect.query(DateTestEntity.class, exp2).selectOne(context);
    assertNotNull(res2);
    assertNotEquals(res1, res2);
}
Also used : Expression(org.apache.cayenne.exp.Expression) DateTestEntity(org.apache.cayenne.testdo.date_time.DateTestEntity) Test(org.junit.Test)

Example 17 with DateTestEntity

use of org.apache.cayenne.testdo.date_time.DateTestEntity in project cayenne by apache.

the class ASTFunctionCallDateIT method testCurrentDate.

@Test
public void testCurrentDate() throws Exception {
    Expression exp = ExpressionFactory.greaterOrEqualExp("dateColumn", new ASTCurrentDate());
    DateTestEntity res1 = ObjectSelect.query(DateTestEntity.class, exp).selectOne(context);
    assertNotNull(res1);
    Expression exp2 = ExpressionFactory.lessExp("dateColumn", new ASTCurrentDate());
    DateTestEntity res2 = ObjectSelect.query(DateTestEntity.class, exp2).selectOne(context);
    assertNotNull(res2);
    assertNotEquals(res1, res2);
}
Also used : Expression(org.apache.cayenne.exp.Expression) DateTestEntity(org.apache.cayenne.testdo.date_time.DateTestEntity) Test(org.junit.Test)

Aggregations

DateTestEntity (org.apache.cayenne.testdo.date_time.DateTestEntity)17 Test (org.junit.Test)15 Calendar (java.util.Calendar)11 Date (java.util.Date)6 Expression (org.apache.cayenne.exp.Expression)6 DataRow (org.apache.cayenne.DataRow)3 EJBQLQuery (org.apache.cayenne.query.EJBQLQuery)3 SelectQuery (org.apache.cayenne.query.SelectQuery)3 Before (org.junit.Before)2 Time (java.sql.Time)1