use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalSecondMethod3 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 day = exprFactory.newLiteral(stmt, mapping, "second");
ArrayList funcArgs = new ArrayList();
funcArgs.add(day);
funcArgs.add(invokedExpr);
NumericExpression secondExpr = new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "date_part", funcArgs);
List castArgs = new ArrayList();
castArgs.add(secondExpr);
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(Integer.class, true), "CAST", castArgs, asList("INTEGER"));
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalSecondMethod5 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");
List secondArgs = new ArrayList();
secondArgs.add(invokedExpr);
NumericExpression secondExpr = new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "SECOND", secondArgs);
List castArgs = new ArrayList();
castArgs.add(secondExpr);
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(Integer.class, true), "CAST", castArgs, asList("INTEGER"));
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalHourMethod2 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, "HOUR");
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, "HH24"));
ArrayList funcArgs2 = new ArrayList();
funcArgs2.add(new StringExpression(stmt, mapping, "TO_CHAR", funcArgs));
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class), "TO_NUMBER", funcArgs2);
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalHourMethod4 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, "HOUR");
RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
SQLExpression hh = exprFactory.newLiteral(stmt, mapping, "hh");
((StringLiteral) hh).generateStatementWithoutQuotes();
ArrayList funcArgs = new ArrayList();
funcArgs.add(hh);
// CAST {invokedExpr} AS DATETIME
List castArgs = new ArrayList<>();
castArgs.add(invokedExpr);
funcArgs.add(new TemporalExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(Date.class), "CAST", castArgs, asList("DATETIME")));
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class), "DATEPART", funcArgs);
}
use of org.datanucleus.store.rdbms.sql.expression.NumericExpression in project datanucleus-rdbms by datanucleus.
the class TemporalIsoYearMethod 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, "ISOYEAR");
invokedExpr.toSQLText().prepend("ISOYEAR FROM ");
return new NumericExpression(stmt, stmt.getSQLExpressionFactory().getMappingForType(int.class, true), "EXTRACT", List.of(invokedExpr));
}
Aggregations