Search in sources :

Example 1 with DateTime

use of org.eclipse.persistence.jpa.jpql.parser.DateTime 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)

Example 2 with DateTime

use of org.eclipse.persistence.jpa.jpql.parser.DateTime in project eclipselink by eclipse-ee4j.

the class AbstractActualJPQLQueryFormatter method visit.

@Override
public void visit(DateTimeStateObject stateObject) {
    if (stateObject.isDecorated()) {
        toText(stateObject);
    } else {
        DateTime expression = stateObject.getExpression();
        appendIdentifier((expression != null) ? expression.getActualIdentifier() : stateObject.getText(), stateObject.getText());
    }
}
Also used : DateTime(org.eclipse.persistence.jpa.jpql.parser.DateTime)

Aggregations

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