use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalDayMethod 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, "DAY");
ArrayList funcArgs = new ArrayList();
funcArgs.add(invokedExpr);
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class), "DAY", funcArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalDayOfWeekMethod2 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, "DAY");
RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
ArrayList funcArgs = new ArrayList();
SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
funcArgs.add(exprFactory.newLiteral(stmt, mapping, "dow"));
funcArgs.add(invokedExpr);
// Add one to the SQL "dow" (origin=0) to be compatible with Java Calendar day of week (origin=1)
SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);
NumericExpression numExpr = new NumericExpression(new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class), "date_part", funcArgs), Expression.OP_ADD, one);
numExpr.encloseInParentheses();
return numExpr;
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class Mod3Operation method getExpression.
/* (non-Javadoc)
* @see org.datanucleus.store.rdbms.sql.operation.SQLOperation#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, org.datanucleus.store.rdbms.sql.expression.SQLExpression)
*/
public SQLExpression getExpression(SQLExpression expr, SQLExpression expr2) {
List args = new ArrayList();
List types = new ArrayList();
types.add("BIGINT");
SQLExpressionFactory exprFactory = expr.getSQLStatement().getSQLExpressionFactory();
List argsOp1 = new ArrayList();
argsOp1.add(expr);
args.add(new NumericExpression(expr.getSQLStatement(), exprFactory.getMappingForType(int.class), "CAST", argsOp1, types));
List argsOp2 = new ArrayList();
argsOp2.add(expr2);
args.add(new NumericExpression(expr.getSQLStatement(), exprFactory.getMappingForType(int.class), "CAST", argsOp2, types));
return new NumericExpression(expr.getSQLStatement(), exprFactory.getMappingForType(int.class), "MOD", args);
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalQuarterMethod5 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, "QUARTER");
invokedExpr.toSQLText().prepend("QUARTER FROM ");
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "EXTRACT", List.of(invokedExpr));
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalSecondMethod2 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, "SECOND");
RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
ArrayList funcArgs = new ArrayList();
funcArgs.add(invokedExpr);
SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
funcArgs.add(exprFactory.newLiteral(stmt, mapping, "SS"));
ArrayList funcArgs2 = new ArrayList();
funcArgs2.add(new StringExpression(stmt, mapping, "TO_CHAR", funcArgs));
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "TO_NUMBER", funcArgs2);
}
Aggregations