use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalMinuteMethod3 method getExpression.
/* (non-Javadoc)
* @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
*/
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
SQLExpression invokedExpr = getInvokedExpression(expr, args, "MINUTE");
RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
SQLExpression day = exprFactory.newLiteral(stmt, mapping, "minute");
ArrayList funcArgs = new ArrayList();
funcArgs.add(day);
funcArgs.add(invokedExpr);
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "date_part", funcArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalMinuteMethod4 method getExpression.
/* (non-Javadoc)
* @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
*/
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
SQLExpression invokedExpr = getInvokedExpression(expr, args, "MINUTE");
RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
SQLExpression mi = exprFactory.newLiteral(stmt, mapping, "mi");
((StringLiteral) mi).generateStatementWithoutQuotes();
ArrayList funcArgs = new ArrayList();
funcArgs.add(mi);
// CAST {invokedExpr} AS DATETIME
List castArgs = new ArrayList<>();
castArgs.add(invokedExpr);
funcArgs.add(new TemporalExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(Date.class, true), "CAST", castArgs, asList("DATETIME")));
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "DATEPART", funcArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalMinuteMethod5 method getExpression.
/* (non-Javadoc)
* @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
*/
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
SQLExpression invokedExpr = getInvokedExpression(expr, args, "MINUTE");
RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
SQLExpression day = exprFactory.newLiteral(stmt, mapping, "%M");
ArrayList funcArgs = new ArrayList();
funcArgs.add(day);
funcArgs.add(invokedExpr);
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "strftime", funcArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalMinuteMethod6 method getExpression.
/* (non-Javadoc)
* @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
*/
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
SQLExpression invokedExpr = getInvokedExpression(expr, args, "MINUTE");
invokedExpr.toSQLText().prepend("MINUTE FROM ");
ArrayList funcArgs = new ArrayList();
funcArgs.add(invokedExpr);
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "EXTRACT", funcArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalMonthJavaMethod method getExpression.
/* (non-Javadoc)
* @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
*/
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
SQLExpression invokedExpr = getInvokedExpression(expr, args, "MONTH_JAVA");
ArrayList funcArgs = new ArrayList();
funcArgs.add(invokedExpr);
NumericExpression monthExpr = new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "MONTH", funcArgs);
// Delete one from the SQL "month" (origin=1) to be compatible with Java month (origin=0)
SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);
NumericExpression numExpr = new NumericExpression(monthExpr, Expression.OP_SUB, one);
numExpr.encloseInParentheses();
return numExpr;
}
Aggregations