Search in sources :

Example 1 with DateConstantExpression

use of org.eclipse.persistence.internal.expressions.DateConstantExpression in project eclipselink by eclipse-ee4j.

the class ExpressionBuilderVisitor method visit.

@Override
public void visit(DateTime expression) {
    if (expression.isJDBCDate()) {
        queryExpression = queryContext.getBaseExpression();
        queryExpression = new DateConstantExpression(expression.getText(), queryExpression);
        String text = expression.getText();
        if (text.startsWith("{d")) {
            type[0] = Date.class;
        } else if (text.startsWith("{ts")) {
            type[0] = Timestamp.class;
        } else if (text.startsWith("{t")) {
            type[0] = Time.class;
        } else {
            type[0] = Object.class;
        }
    } else {
        queryExpression = queryContext.getBaseExpression();
        if (expression.isCurrentDate()) {
            queryExpression = queryExpression.currentDateDate();
            type[0] = Date.class;
        } else if (expression.isCurrentTime()) {
            queryExpression = queryExpression.currentTime();
            type[0] = Time.class;
        } else if (expression.isCurrentTimestamp()) {
            queryExpression = queryExpression.currentTimeStamp();
            type[0] = Timestamp.class;
        } else {
            throw new IllegalArgumentException("The DateTime is unknown: " + expression);
        }
    }
}
Also used : Time(java.sql.Time) DateTime(org.eclipse.persistence.jpa.jpql.parser.DateTime) Timestamp(java.sql.Timestamp) DateConstantExpression(org.eclipse.persistence.internal.expressions.DateConstantExpression)

Aggregations

Time (java.sql.Time)1 Timestamp (java.sql.Timestamp)1 DateConstantExpression (org.eclipse.persistence.internal.expressions.DateConstantExpression)1 DateTime (org.eclipse.persistence.jpa.jpql.parser.DateTime)1