use of org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory in project datanucleus-rdbms by datanucleus.
the class TemporalDayMethod4 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, "%d"));
funcArgs.add(invokedExpr);
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class), "strftime", funcArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory in project datanucleus-rdbms by datanucleus.
the class NumericToString2Operation 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) {
SQLExpressionFactory exprFactory = expr.getSQLStatement().getSQLExpressionFactory();
JavaTypeMapping m = exprFactory.getMappingForType(String.class, false);
if (expr instanceof SQLLiteral) {
// Just convert the literal value directly
if (((SQLLiteral) expr).getValue() == null) {
return new StringLiteral(expr.getSQLStatement(), m, null, null);
}
return new StringLiteral(expr.getSQLStatement(), m, ((SQLLiteral) expr).getValue().toString(), null);
}
List args = new ArrayList();
args.add(expr);
List types = new ArrayList();
types.add("CHAR(4000)");
return new StringExpression(expr.getSQLStatement(), m, "CAST", args, types);
}
use of org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory in project datanucleus-rdbms by datanucleus.
the class NumericToString3Operation 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) {
SQLExpressionFactory exprFactory = expr.getSQLStatement().getSQLExpressionFactory();
JavaTypeMapping m = exprFactory.getMappingForType(String.class, false);
if (expr instanceof SQLLiteral) {
// Just convert the literal value directly
if (((SQLLiteral) expr).getValue() == null) {
return new StringLiteral(expr.getSQLStatement(), m, null, null);
}
return new StringLiteral(expr.getSQLStatement(), m, ((SQLLiteral) expr).getValue().toString(), null);
}
List args = new ArrayList();
args.add(expr);
List trimArgs = new ArrayList();
trimArgs.add(new StringExpression(expr.getSQLStatement(), m, "CHAR", args));
return new StringExpression(expr.getSQLStatement(), m, "RTRIM", trimArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory in project datanucleus-rdbms by datanucleus.
the class TemporalSecondMethod6 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);
SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
SQLExpression sec = exprFactory.newLiteral(stmt, mapping, "%S");
ArrayList funcArgs = new ArrayList();
funcArgs.add(sec);
funcArgs.add(invokedExpr);
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class), "strftime", funcArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory in project datanucleus-rdbms by datanucleus.
the class TemporalYearMethod2 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, "YEAR");
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, "YYYY"));
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