use of org.datanucleus.store.rdbms.sql.expression.StringExpression 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.StringExpression 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.StringExpression in project datanucleus-rdbms by datanucleus.
the class NumericToStringOperation 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) {
JavaTypeMapping m = expr.getSQLStatement().getSQLExpressionFactory().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("VARCHAR(4000)");
return new StringExpression(expr.getSQLStatement(), m, "CAST", args, types);
}
use of org.datanucleus.store.rdbms.sql.expression.StringExpression 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);
}
use of org.datanucleus.store.rdbms.sql.expression.StringExpression in project datanucleus-rdbms by datanucleus.
the class Concat2Operation 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) {
RDBMSStoreManager storeMgr = expr.getSQLStatement().getRDBMSManager();
JavaTypeMapping m = storeMgr.getSQLExpressionFactory().getMappingForType(String.class, false);
ArrayList args = new ArrayList();
args.add(expr);
args.add(expr2);
return new StringExpression(expr.getSQLStatement(), m, "CONCAT", args);
}
Aggregations