use of org.apache.cayenne.testdo.date_time.DateTestEntity in project cayenne by apache.
the class ASTFunctionCallDateIT method testASTCurrentTimestampParse.
@Test
public void testASTCurrentTimestampParse() {
Expression exp = ExpressionFactory.exp("timestampColumn > now()");
DateTestEntity res = ObjectSelect.query(DateTestEntity.class, exp).selectOne(context);
assertNotNull(res);
}
use of org.apache.cayenne.testdo.date_time.DateTestEntity in project cayenne by apache.
the class ASTFunctionCallDateIT method testASTCurrentDateParse.
@Test
public void testASTCurrentDateParse() {
Expression exp = ExpressionFactory.exp("dateColumn > currentDate()");
DateTestEntity res = ObjectSelect.query(DateTestEntity.class, exp).selectOne(context);
assertNotNull(res);
}
use of org.apache.cayenne.testdo.date_time.DateTestEntity in project cayenne by apache.
the class ASTFunctionCallDateIT method testCurrentTimestamp.
@Test
public void testCurrentTimestamp() throws Exception {
Expression exp = ExpressionFactory.greaterOrEqualExp("timestampColumn", new ASTCurrentTimestamp());
DateTestEntity res1 = ObjectSelect.query(DateTestEntity.class, exp).selectOne(context);
assertNotNull(res1);
Expression exp2 = ExpressionFactory.lessExp("timestampColumn", new ASTCurrentTimestamp());
DateTestEntity res2 = ObjectSelect.query(DateTestEntity.class, exp2).selectOne(context);
assertNotNull(res2);
assertNotEquals(res1, res2);
}
use of org.apache.cayenne.testdo.date_time.DateTestEntity in project cayenne by apache.
the class ASTFunctionCallDateIT method createDataSet.
@Before
public void createDataSet() throws Exception {
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_MONTH);
DateTestEntity o1 = context.newObject(DateTestEntity.class);
cal.set(year - 1, month, day, 0, 0, 0);
o1.setDateColumn(cal.getTime());
cal.set(year, month, day, 0, 0, 0);
o1.setTimeColumn(cal.getTime());
cal.set(Calendar.DAY_OF_MONTH, day - 1);
o1.setTimestampColumn(cal.getTime());
DateTestEntity o2 = context.newObject(DateTestEntity.class);
cal.set(year + 1, month, day, 0, 0, 0);
o2.setDateColumn(cal.getTime());
cal.set(year, month, day, 23, 59, 59);
o2.setTimeColumn(cal.getTime());
cal.set(Calendar.DAY_OF_MONTH, day + 1);
o2.setTimestampColumn(cal.getTime());
context.commitChanges();
}
use of org.apache.cayenne.testdo.date_time.DateTestEntity in project cayenne by apache.
the class DataContextEJBQLDateTimeFunctionalExpressionsIT method testCURRENT_DATE.
@Test
public void testCURRENT_DATE() {
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
DateTestEntity o1 = context.newObject(DateTestEntity.class);
cal.set(year - 3, 1, 1);
o1.setDateColumn(cal.getTime());
DateTestEntity o2 = context.newObject(DateTestEntity.class);
cal.set(year + 3, 1, 1);
o2.setDateColumn(cal.getTime());
context.commitChanges();
EJBQLQuery query = new EJBQLQuery("SELECT d FROM DateTestEntity d WHERE d.dateColumn > CURRENT_DATE");
List<?> objects = context.performQuery(query);
assertEquals(1, objects.size());
assertTrue(objects.contains(o2));
}
Aggregations